Advertisement
Guest User

Untitled

a guest
Aug 24th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. resFile <- "DESeq2_result_name" # has to have entrez ids as annotations
  2. compName <- "comparison" # Name of the comparison
  3.  
  4. calcSPIA <- function(resFile, compName)
  5. {
  6. res <- read.table(resFile, header = T, sep = "\t", fill=T, quote = "\"", stringsAsFactors = F)
  7.  
  8. # Select differentially expressed genes (adjusted p-value < 0.05)
  9. # This is a named vector, where names are entrez ids, and values are log2 fold changes
  10. ids <- res[res$padj < 0.05,]$entrezgene_id
  11. logFC <- res[res$padj < 0.05,]$log2FoldChange
  12. DE_genes <- logFC
  13. names(DE_genes) <- ids
  14. DE_genes <- DE_genes[!is.na(names(DE_genes))]
  15.  
  16. # Get all expressed genes entrez ids
  17. ALL_genes <- res$entrezgene_id
  18. ALL_genes <- ALL_genes[!is.na(ALL_genes)]
  19. res <- spia(de=DE_genes, all=ALL_genes, organism="hsa", nB=2000, plots=FALSE, beta=NULL, combine="fisher", verbose=FALSE)
  20. write.table(res, file=paste(compName, "_SPIA_result.txt", sep = ""), sep = "\t", col.names = T, row.names = F, quote = F)
  21.  
  22. tiff(file=paste(compName, "_SPIA_result.tiff", sep = ""), width=500, height=500)
  23. plotP(res, threshold = 0.05)
  24. dev.off()
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement