Question: DMRcate: Cpgids in DMR
0
gravatar for yoursbassanio
13 days ago by
yoursbassanio0 wrote:

The below is my Dmrcate run and I do get the DMRS. but how to get the CPGids that are part of these DMRS

corfit <- duplicateCorrelation(myMs, design=designMatrix, block = biolrep)
dmrCate.<-cpg.annotate("array", myMs, what="M", arraytype = "EPIC", analysis.type="differential", design=designMatrix, coef=2, block=biolrep, correlation=corfit$consensus.correlation,fdr=0.01)
dmrcoutput_all <- dmrcate(dmrCate,lambda=500, C=5, pcutoff="fdr",min.cpgs=1,mc.cores=1)
wgbs.ranges_all.snp7 <- extractRanges(dmrcoutput_all, genome = "hg19")
write.csv (wgbs.ranges_all.snp7,file="DMRCate_DifferentailRange.txt")
write.csv(dmrcoutput_all.snp7$results,file="DMRCate_ALL.txt")

how to get the 17 Cpgids from the result shown below

"","seqnames","start","end","width","strand","no.cpgs","minfdr","Stouffer","maxbetafc","meanbetafc","overlapping.promoters"
"1","chr6",31539539,31540750,1212,"*",17,2.06654851019045e-120,2.16758469969414e-149,-0.162022961391297,-0.106211449278892,"LTA-001, LTA-002, LTA-004, LTA-003"

I tried with gRanges but unable to understand how to perform it

ADD COMMENTlink modified 12 days ago by James W. MacDonald51k • written 13 days ago by yoursbassanio0
1
 gr <- granges(OBJECT)
locs.ranges<-names(gr[seqnames(gr) == "chr6" & start(gr)>=31539539 & end(gr) <=31540750 ])

The above two lines I was able to subset the ids belonging to 1 location of interest.

But now How can I loop this for multiple locations present in a data.frame of dmrcoutput_all?

ADD REPLYlink written 12 days ago by yoursbassanio0
1

There would be multiple ways(more efficient way ) to what do than the below script which I have used solve my own problem.

But It would be great to know If there is any efficient way to do the same.

OBJECT <- is the last object from which beta/mvalue for DMRCate is give as input

    gr <- granges(OBJECT)

 #read DMRcate outputstringsAsFactors = FALSE ;else there issue by creating levels
 mydata<-read.csv(file="DMRCate_Output.csv",header=TRUE,stringsAsFactors = FALSE)  

    for(n in 1:nrow(mydata)) 
    {

      # chr is the second column
      chr<-mydata2[n,2]   

      # DMR start is in 3rd column
       start=mydata2[n,3]   

       #DMR end is in 4th column
       end=mydata2[n,4]   

     #strand where all "*" so not included while retrieving
      #Start and end pos included 
      infos<-names(gr[seqnames(gr) == chr & start(gr)>=start & end(gr) <=end ])  

      allcpg<-toString(infos)
      mydata$cpgids<-allcpg
    }

    write.table(mydata,file="DMRCate_Model3_DifferentailRange_V3V4_withCpgids",sep="\t");

P.S: Here the output from DMRcate is written to a file

ADD REPLYlink modified 12 days ago • written 12 days ago by yoursbassanio0
 gr <- granges(OBJECT)
locs.ranges<-names(gr[seqnames(gr) == "chr6" & start(gr)>=31539539 & end(gr) <=31540750 ])

The above two lines I was able to subset the ids belonging to 1 location of interest.

How can I loop this for multiple locations present in a data.frame of dmrcoutput_all?

ADD REPLYlink modified 12 days ago • written 12 days ago by yoursbassanio0
Answer: DMRcate: Cpgids in DMR
0
gravatar for James W. MacDonald
12 days ago by
United States
James W. MacDonald51k wrote:

You don't say what your starting object is, so you are asking us to read your mind. If I were to do so, I would divine that you used minfi to import and process your data, and you have a GenomicRatioSet that you got your M-values from. And since that's obviously what you did, you can just do

firstrow <- subsetByOverlaps(OBJECT, wgbs.ranges_all.snp7[1,])

Which will give you a GenomicRatioSet that only contains the data that overlap the first DMR. Which you can do things with. Also, read the vignettes for GenomicRanges.

ADD COMMENTlink written 12 days ago by James W. MacDonald51k

Also, if you aren't answering your own question (which it appears you weren't?), don't use the Add your answer box, but instead ADD REPLY or ADD COMMENT.

ADD REPLYlink written 12 days ago by James W. MacDonald51k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 206 users visited in the last hour