Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving separate dotplots with for loop #48

Open
mirkocelii opened this issue Mar 18, 2021 · 1 comment
Open

Saving separate dotplots with for loop #48

mirkocelii opened this issue Mar 18, 2021 · 1 comment

Comments

@mirkocelii
Copy link

hello,
I want to create several PDF files with Functional_enrichment Doplot as Chipseeker vignette with a for loop.
http://bioconductor.org/packages/devel/bioc/vignettes/ChIPseeker/inst/doc/ChIPseeker.html
but the PDF are empty with no pages.

If I avoid the for loop e run the commands one by one, it works.
am I doing something wrong?
this is the code

library(ReactomePA)
library(ChIPseeker)
library(TxDb.Hsapiens.UCSC.hg19.knownGene)
txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene
library(clusterProfiler)

files <- getSampleFiles()
peakList         <- lapply(files, readPeakFile)
peakAnnoList <- lapply(files, annotatePeak, TxDb=txdb, tssRegion=c(-3000, 3000), verbose=FALSE)


for( i in names(peakAnnoList))
{
    cat(i)
    peak         = peakList[[i]]
    peakAnno = peakAnnoList[[i]]
    
    pathway1 <- enrichPathway(as.data.frame(peakAnno)$geneId)
    head(pathway1, 2)
    
    gene <- seq2gene(peak, tssRegion = c(-1000, 1000), flankDistance = 3000, TxDb=txdb)
    pathway2 <- enrichPathway(gene)
    head(pathway2, 2)
    
    pdf( paste("Functional_enrichment",i,"pathway1.pdf",sep="."),10,10)
    dotplot( pathway1,title = paste("Functional enrichment", sam))
    dev.off()  
    
    pdf( paste("Functional_enrichment",i,"pathway2.pdf",sep="."),10,10)
    dotplot( pathway2,title = paste("Functional enrichment", sam))
    dev.off()  
    
    }
@mirkocelii mirkocelii changed the title Saving dotplots a for loop Saving separate dotplots with for loop Mar 18, 2021
@GuangchuangYu
Copy link
Member

try print the dotplot.

pdf(file)
print(dotplot())
dev.off()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants