This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Help with error using ClosetFeature() in Signac

Hi all,

I try to add gene name to differential accessibility peaks by using ClosestFeature():

da_peaks$closest_gene <- ClosestFeature(data, regions = rownames(da_peaks))$gene_name

However I got this:

Error in $<-.data.frame(*tmp*, closest_gene, value = c("MIB2", "SKI", : replacement has 49180 rows, data has 49193

The da_peaks has 49193 rows meanwhile I only have 49180 genes so how can I modify them to make them equal? Would you please tell me how to fix this error? Thank you so much!
https://stuartlab.org/signac/articles/pbmc_vignette

signac atac

1 answer

Your function is not correct. You can do this instead.

my_regions=rownames(da_peaks[da_peaks$avg_log2FC > X, ]) # X will be your criteria 0.5, 1, 1.5, 2 or 3 etc 
da_peak_closest_gene <- ClosestFeature(data, regions=my_regions)
head(da_peak_closest_gene)

You r welcome! Please go ahead and accept the answer if that had worked for you.

So if I want to add a new column name closets_gene indo da_peaks, would you recommend a way to fix this error? Seem I have 13 peaks that don't have equivalent genes which cause the error.

Log in to answer this question.