viewApply drops feature names; transfer names between lists
0
0
Entering edit mode
Chris Seidel ▴ 70
@chris-seidel-5840
Last seen just now
United States
Hello, I have a set of gene features on which I calculated coverage using Views: # get coverage for a tss RangesList tss.cov <- mapply(Views,mycov,tss.RL) # convert from list to SimpleRleViewsList tss.cov <- RleViewsList(tss.cov) # summarize values using mean or median tss.avg <- viewMeans(tss.cov) tss.med <- viewApply(tss.cov, median) tss.cov has names for each gene feature: > class(tss.cov) [1] "SimpleRleViewsList" attr(,"package") [1] "IRanges" > tss.cov[[1]][1:3] Views on a 230218-length Rle subject views: start end width [1] 99205 99404 200 [11.30 11.30 11.20 11.20 11.20 ...etc. [2] 142267 142466 200 [20.3 20.3 20.1 20.0 19.8 19.1 ...etc. [3] 166167 166366 200 [14.9 14.9 15.1 15.1 15.1 15.1 ...etc. > names(tss.cov[[1]])[1:3] [1] "HRA1" "snR18" "tA(UGC)A" When using viewMeans, the names are preserved in the result: > names(tss.avg[[1]]) [1] "HRA1" "snR18" "tA(UGC)A"...etc. But when using viewApply(), the feature names are lost: > names(tss.med[[1]]) NULL Is there a good way to transfer the names from the target of veiwApply() to the result? A for loop works: for( i in 1:length(tss.cov) ){ names(tss.med[[i]]) <- names(tss.cov[[i]]) } but it's been drilled into me that if I'm using a for loop in R, I'm doing something wrong. And I get the sense there's an elegant one liner for this. Thanks, -Chris > sessionInfo() R version 3.1.0 (2014-04-10) other attached packages: [1] rtracklayer_1.24.0 GenomicFeatures_1.16.0 AnnotationDbi_1.26.0 Biobase_2.24.0 GenomicRanges_1.16.2 GenomeInfoDb_1.0.2 IRanges_1.22.3 [8] BiocGenerics_0.10.0
Coverage convert Coverage convert • 639 views
ADD COMMENT

Login before adding your answer.

Traffic: 428 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