Mercurial > repos > fubar > differential_count_models
comparison rgedgeR/rgedgeRpaired.xml @ 13:f542654faa3b draft
Uploaded
author | fubar |
---|---|
date | Sat, 27 Jul 2013 02:18:41 -0400 |
parents | aa528c834664 |
children | 8272815ba8ce |
comparison
equal
deleted
inserted
replaced
12:aa528c834664 | 13:f542654faa3b |
---|---|
399 nzN = nrow(nonzerod) | 399 nzN = nrow(nonzerod) |
400 nzrs = rowSums(nonzerod) | 400 nzrs = rowSums(nonzerod) |
401 zN = allN - nzN | 401 zN = allN - nzN |
402 print('# Quantiles for non-zero row counts:',quote=F) | 402 print('# Quantiles for non-zero row counts:',quote=F) |
403 print(quantile(nzrs,probs=seq(0,1,0.1)),quote=F) | 403 print(quantile(nzrs,probs=seq(0,1,0.1)),quote=F) |
404 if (useNDF == "T") | 404 if (useNDF == T) |
405 { | 405 { |
406 gt1rpin3 = rowSums(Count_Matrix/expandAsMatrix(colTotmillionreads,dim(Count_Matrix)) >= 1) >= nscut | 406 gt1rpin3 = rowSums(Count_Matrix/expandAsMatrix(colTotmillionreads,dim(Count_Matrix)) >= 1) >= nscut |
407 lo = colSums(Count_Matrix[!gt1rpin3,]) | 407 lo = colSums(Count_Matrix[!gt1rpin3,]) |
408 workCM = Count_Matrix[gt1rpin3,] | 408 workCM = Count_Matrix[gt1rpin3,] |
409 cleanrs = rowSums(workCM) | 409 cleanrs = rowSums(workCM) |
510 dev.off() | 510 dev.off() |
511 colnames(normData) = paste( colnames(normData),'N',sep="_") | 511 colnames(normData) = paste( colnames(normData),'N',sep="_") |
512 print(paste('Raw sample read totals',paste(colSums(nonzerod,na.rm=T),collapse=','))) | 512 print(paste('Raw sample read totals',paste(colSums(nonzerod,na.rm=T),collapse=','))) |
513 nzd = data.frame(log(nonzerod + 1e-2,10)) | 513 nzd = data.frame(log(nonzerod + 1e-2,10)) |
514 boxPlot(rawrs=nzd,cleanrs=log(normData,10),maint='TMM Normalisation',myTitle=myTitle,pdfname="edgeR_raw_norm_counts_box.pdf") | 514 boxPlot(rawrs=nzd,cleanrs=log(normData,10),maint='TMM Normalisation',myTitle=myTitle,pdfname="edgeR_raw_norm_counts_box.pdf") |
515 write.table(soutput,out_edgeR, quote=FALSE, sep="\t",row.names=F) | 515 write.table(soutput,file=out_edgeR, quote=FALSE, sep="\t",row.names=F) |
516 tt = cbind( | 516 tt = cbind( |
517 Name=as.character(rownames(DGEList\$counts)), | 517 Name=as.character(rownames(DGEList\$counts)), |
518 DE\$table, | 518 DE\$table, |
519 adj.p.value=p.adjust(DE\$table\$PValue, method=fdrtype), | 519 adj.p.value=p.adjust(DE\$table\$PValue, method=fdrtype), |
520 Dispersion=DGEList\$tagwise.dispersion,totreads=cmrowsums | 520 Dispersion=DGEList\$tagwise.dispersion,totreads=cmrowsums |
565 rDESeq = cbind(Contig=rownames(workCM),rDESeq,NReads=cmrowsums,URL=contigurls) | 565 rDESeq = cbind(Contig=rownames(workCM),rDESeq,NReads=cmrowsums,URL=contigurls) |
566 srDESeq = rDESeq[order(rDESeq\$pvalue),] | 566 srDESeq = rDESeq[order(rDESeq\$pvalue),] |
567 qqPlot(descr=paste(myTitle,'DESeq2 qqplot'),pvector=rDESeq\$pvalue,outpdf='DESeq2_qqplot.pdf') | 567 qqPlot(descr=paste(myTitle,'DESeq2 qqplot'),pvector=rDESeq\$pvalue,outpdf='DESeq2_qqplot.pdf') |
568 cat("# DESeq top 50\n") | 568 cat("# DESeq top 50\n") |
569 print.noquote(srDESeq[1:50,]) | 569 print.noquote(srDESeq[1:50,]) |
570 write.table(srDESeq,out_DESeq2, quote=FALSE, sep="\t",row.names=F) | 570 write.table(srDESeq,file=out_DESeq2, quote=FALSE, sep="\t",row.names=F) |
571 topresults.DESeq = rDESeq[which(rDESeq\$padj < fdrthresh), ] | 571 topresults.DESeq = rDESeq[which(rDESeq\$padj < fdrthresh), ] |
572 DESeqcountsindex = which(allgenes %in% rownames(topresults.DESeq)) | 572 DESeqcountsindex = which(allgenes %in% rownames(topresults.DESeq)) |
573 DESeqcounts = rep(0, length(allgenes)) | 573 DESeqcounts = rep(0, length(allgenes)) |
574 DESeqcounts[DESeqcountsindex] = 1 | 574 DESeqcounts[DESeqcountsindex] = 1 |
575 pdf("DESeq2_dispersion_estimates.pdf") | 575 pdf("DESeq2_dispersion_estimates.pdf") |
621 rvoom = topTable(fit, coef = length(colnames(mydesign)), adj = fdrtype, n = Inf, sort="none") | 621 rvoom = topTable(fit, coef = length(colnames(mydesign)), adj = fdrtype, n = Inf, sort="none") |
622 qqPlot(descr=paste(myTitle,'VOOM-limma QQ plot'),pvector=rvoom\$P.Value,outpdf='VOOM_qqplot.pdf') | 622 qqPlot(descr=paste(myTitle,'VOOM-limma QQ plot'),pvector=rvoom\$P.Value,outpdf='VOOM_qqplot.pdf') |
623 rownames(rvoom) = rownames(workCM) | 623 rownames(rvoom) = rownames(workCM) |
624 rvoom = cbind(rvoom,NReads=cmrowsums,URL=contigurls) | 624 rvoom = cbind(rvoom,NReads=cmrowsums,URL=contigurls) |
625 srvoom = rvoom[order(rvoom\$P.Value),] | 625 srvoom = rvoom[order(rvoom\$P.Value),] |
626 write.table(srvoom,out_VOOM, quote=FALSE, sep="\t",row.names=F) | 626 cat("# VOOM top 50\n") |
627 print(srvoom[1:50,]) | |
628 write.table(srvoom,file=out_VOOM, quote=FALSE, sep="\t",row.names=F) | |
627 # Use an FDR cutoff to find interesting samples for edgeR, DESeq and voom/limma | 629 # Use an FDR cutoff to find interesting samples for edgeR, DESeq and voom/limma |
628 topresults.voom = srvoom[which(rvoom\$adj.P.Val < fdrthresh), ] | 630 topresults.voom = srvoom[which(rvoom\$adj.P.Val < fdrthresh), ] |
629 voomcountsindex = which(allgenes %in% topresults.voom\$ID) | 631 voomcountsindex = which(allgenes %in% topresults.voom\$ID) |
630 voomcounts = rep(0, length(allgenes)) | 632 voomcounts = rep(0, length(allgenes)) |
631 voomcounts[voomcountsindex] = 1 | 633 voomcounts[voomcountsindex] = 1 |
632 cat("# VOOM top 50\n") | |
633 print(srvoom[1:50,]) | |
634 sink() | 634 sink() |
635 } | 635 } |
636 | 636 |
637 if (doCamera) { | 637 if (doCamera) { |
638 doGSEA(y=DGEList,design=mydesign,histgmt=histgmt,bigmt=bigmt,ntest=20,myTitle=myTitle, | 638 doGSEA(y=DGEList,design=mydesign,histgmt=histgmt,bigmt=bigmt,ntest=20,myTitle=myTitle, |
669 ###sink(stdout(),append=T,type="message") | 669 ###sink(stdout(),append=T,type="message") |
670 builtin_gmt="" | 670 builtin_gmt="" |
671 history_gmt="" | 671 history_gmt="" |
672 out_edgeR = F | 672 out_edgeR = F |
673 out_DESeq2 = F | 673 out_DESeq2 = F |
674 out_VOOM = F | 674 out_VOOM = "${out_VOOM}" |
675 doDESeq2 = $DESeq2.doDESeq2 # make these T or F | 675 doDESeq2 = $DESeq2.doDESeq2 # make these T or F |
676 doVoom = $doVoom | 676 doVoom = $doVoom |
677 doCamera = F | 677 doCamera = F |
678 doedgeR = $edgeR.doedgeR | 678 doedgeR = $edgeR.doedgeR |
679 edgeR_priordf = 0 | 679 edgeR_priordf = 0 |
680 | 680 |
681 #if $DESeq2.doDESeq2 == "T": | 681 |
682 out_DESeq2 = "$out_DESeq2" | 682 #if ${doVoom} == "T": |
683 DESeq_fitType = "$DESeq2.DESeq_fitType" | 683 out_VOOM = "${out_VOOM}" |
684 #end if | 684 #end if |
685 #if $edgeR.doedgeR == "T": | 685 |
686 out_edgeR = "$out_edgeR" | 686 #if ${DESeq2.doDESeq2} == "T": |
687 edgeR_priordf = $edgeR.edgeR_priordf | 687 out_DESeq2 = "${out_DESeq2}" |
688 DESeq_fitType = "${DESeq2.DESeq_fitType}" | |
688 #end if | 689 #end if |
689 #if $doVoom == "T": | 690 |
690 out_VOOM = "$out_VOOM" | 691 #if ${edgeR.doedgeR} == "T": |
692 out_edgeR = "${out_edgeR}" | |
693 edgeR_priordf = ${edgeR.edgeR_priordf} | |
691 #end if | 694 #end if |
692 | 695 |
693 Out_Dir = "$html_file.files_path" | 696 Out_Dir = "$html_file.files_path" |
694 Input = "$input1" | 697 Input = "$input1" |
695 TreatmentName = "$treatment_name" | 698 TreatmentName = "$treatment_name" |
698 ControlCols= "$Control_cols" | 701 ControlCols= "$Control_cols" |
699 org = "$input1.dbkey" | 702 org = "$input1.dbkey" |
700 if (org == "") { org = "hg19"} | 703 if (org == "") { org = "hg19"} |
701 fdrtype = "$fdrtype" | 704 fdrtype = "$fdrtype" |
702 fdrthresh = $fdrthresh | 705 fdrthresh = $fdrthresh |
703 useNDF = "$useNDF" | 706 useNDF = $useNDF |
704 fQ = $fQ # non-differential centile cutoff | 707 fQ = $fQ # non-differential centile cutoff |
705 myTitle = "$title" | 708 myTitle = "$title" |
706 subjects = c($subjectids) | 709 subjects = c($subjectids) |
707 nsubj = length(subjects) | 710 nsubj = length(subjects) |
708 if (nsubj > 0) { | 711 if (nsubj > 0) { |
738 LibSizes = Count_Matrix[subset(rn,islib),][1] # take first | 741 LibSizes = Count_Matrix[subset(rn,islib),][1] # take first |
739 Count_Matrix = Count_Matrix[subset(rn,! islib),] | 742 Count_Matrix = Count_Matrix[subset(rn,! islib),] |
740 group = c(rep(TreatmentName,length(TCols)), rep(ControlName,length(CCols)) ) #Build a group descriptor | 743 group = c(rep(TreatmentName,length(TCols)), rep(ControlName,length(CCols)) ) #Build a group descriptor |
741 group = factor(group, levels=c(ControlName,TreatmentName)) | 744 group = factor(group, levels=c(ControlName,TreatmentName)) |
742 colnames(Count_Matrix) = paste(group,colnames(Count_Matrix),sep="_") #Relable columns | 745 colnames(Count_Matrix) = paste(group,colnames(Count_Matrix),sep="_") #Relable columns |
743 results = edgeIt(Count_Matrix=Count_Matrix,group=group,out_edgeR=out_edgeR, out_VOOM=out_VOOM, out_DESeq2=out_DESeq2, | 746 results = edgeIt(Count_Matrix=Count_Matrix,group=group, out_edgeR=out_edgeR, out_VOOM=out_VOOM, out_DESeq2=out_DESeq2, |
744 fdrtype='BH',priordf=edgeR_priordf,fdrthresh=0.05,outputdir='.', | 747 fdrtype='BH',priordf=edgeR_priordf,fdrthresh=0.05,outputdir='.', |
745 myTitle=myTitle,useNDF=F,libSize=c(),filterquantile=fQ,subjects=c(), | 748 myTitle=myTitle,useNDF=F,libSize=c(),filterquantile=fQ,subjects=c(), |
746 doDESeq2=doDESeq2,doVoom=doVoom,doCamera=doCamera,doedgeR=doedgeR,org=org, | 749 doDESeq2=doDESeq2,doVoom=doVoom,doCamera=doCamera,doedgeR=doedgeR,org=org, |
747 histgmt=history_gmt,bigmt=builtin_gmt,DESeq_fitType=DESeq_fitType) | 750 histgmt=history_gmt,bigmt=builtin_gmt,DESeq_fitType=DESeq_fitType) |
748 sessionInfo() | 751 sessionInfo() |