Entering edit mode
kristina_holton
•
0
@kristina_holton-12527
Last seen 7.8 years ago
Hi,
I'm looking for input on what the best way to implement the VariantAnnotation mapToTranscripts function would be, over a 48k rows data frame (data2). I just need a vector of the CDS position. I have access to an HPC, R 3.3.1 or R 3.2.5 with high memory allocations. Here's the code I'm working with. Thanks! -Kris
head(data2[,c(1,2)], n=10) V1 V2 1: chr9 76068032 2: chr9 76068032 3: chr9 92500968 4: chr9 92500968 5: chr9 120833319 6: chr9 120833319 7: chr9 92514974 8: chr9 92514974 9: chr9 134727395 10: chr9 134727395 library(VariantAnnotation) library(TxDb.Hsapiens.UCSC.hg38.knownGene) txdb<-TxDb.Hsapiens.UCSC.hg38.knownGene cds <- cdsBy(txdb, "tx", use.names=TRUE) get.cds.start<-function(i) { chrom<-data2[i]$V1 pos<-data2[i]$V2 roi<-GRanges(chrom, IRanges(pos, width=1)) mapped<-mapToTranscripts(roi, cds) cds.pos<-start(mapped)[1] if (is.null(cds.pos)){ break } return(cds.pos) } cds.start<-sapply(1:length(data2), get.cds.start)