Dear all,
I'm trying to include a Bioconductor package specific function in a for loop to output pdf files.
Specifically, I ran the Swimming downstream workflow and look for DTU in 2 group of samples. After stageR following DEXSeq, I got a table dex.padj with transcripts with DTU.
geneID txID gene transcript 1 FBgn0000008 FBtr0100521 1.133918e-02 0 2 FBgn0000008 FBtr0071763 1.133918e-02 0 3 FBgn0000053 FBtr0079431 1.706116e-04 0 4 FBgn0000053 FBtr0100353 1.706116e-04 0 5 FBgn0000182 FBtr0080804 5.051515e-13 0 6 FBgn0000182 FBtr0080803 5.051515e-13 0
I want to use the plotProportions function from DRIMSeq to output a pdf for each gene.
I came up with a for loop here. It created empty pdfs with correct names.
for (i in 1:length(unique(dex.padj$geneID))){ pdf(paste(unique(dex.padj$geneID)[i],".pdf", sep = ""), width = 11, height = 8.5) plotProportions(d, res$gene_id[res$gene_id==unique(dex.padj$geneID)[i]], "celltype") dev.off() }
I guess the plotProportions function did not work in the loop? I suspect this is the problem
What's the best way to go about it? An sapply solution would be lovely.
Thank you!
Wanpeng