Help with error using ClosetFeature() in Signac
1
0
Entering edit mode
15 months ago
Chris ▴ 340

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 • 890 views
ADD COMMENT
2
Entering edit mode
15 months ago
bk11 ★ 3.0k

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)
ADD COMMENT
0
Entering edit mode

Thank you for your help! No error with your code. However, I try to follow this one: https://github.com/mousepixels/sanbomics_scripts/blob/main/scATAC_intro_R.Rmd.
which has a little modification, so when I try to add a new column name closets_gene into da_peaks, I will get error because two value is not the same.

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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.

ADD REPLY

Login before adding your answer.

Traffic: 2654 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6