Question: Calling a package specific function in a for loop
0
gravatar for georgewwp
11 months ago by
georgewwp0
georgewwp0 wrote:

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

ADD COMMENTlink modified 11 months ago by Martin Morgan ♦♦ 24k • written 11 months ago by georgewwp0
Answer: Calling a package specific function in a for loop
1
gravatar for Martin Morgan
11 months ago by
Martin Morgan ♦♦ 24k
United States
Martin Morgan ♦♦ 24k wrote:

Try using print(plotProportions(...)).

ADD COMMENTlink written 11 months ago by Martin Morgan ♦♦ 24k
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: 202 users visited in the last hour