Ver código fonte

上传文件至 '.'

master
yingyu 6 anos atrás
pai
commit
e37fcb7190
5 arquivos alterados com 32 adições e 15 exclusões
  1. +1
    -1
      RNAseq_2_pca.R
  2. +1
    -2
      RNAseq_3_cor.R
  3. +1
    -2
      RNAseq_4_pwDEG.R
  4. +1
    -2
      RNAseq_5_pwGSEA.R
  5. +28
    -8
      RNAseq_6_enrichfunc.R

+ 1
- 1
RNAseq_2_pca.R Ver arquivo



##import exp file ##import exp file
out_dir<-paste(gsub("/$","",opt$out_dir),"/",sep="") out_dir<-paste(gsub("/$","",opt$out_dir),"/",sep="")
logexpr<-fread(opt$input,header=T,stringsAsFactors=F,row.names=1,check.names=F,data.table=F)
logexpr<-read.table(opt$input,header=T,stringsAsFactors=F,row.names=1,check.names=F)


#check exp file is log scale #check exp file is log scale
if(max(logexpr[,1])-min(logexpr[,1])>100){ if(max(logexpr[,1])-min(logexpr[,1])>100){

+ 1
- 2
RNAseq_3_cor.R Ver arquivo

# Rscript RNAseq_3_cor.R -o /home/yuying/rnaseqreport_test -i ballgown_geneexp_log2fpkm_floor0p01_c3r58395_2019-04-29.txt -g group1.txt -p organoid # Rscript RNAseq_3_cor.R -o /home/yuying/rnaseqreport_test -i ballgown_geneexp_log2fpkm_floor0p01_c3r58395_2019-04-29.txt -g group1.txt -p organoid


suppressPackageStartupMessages(library("optparse")) suppressPackageStartupMessages(library("optparse"))
suppressPackageStartupMessages(library("data.table"))


# specify our desired options in a list # specify our desired options in a list
# by default OptionParser will add an help option equivalent to # by default OptionParser will add an help option equivalent to


##import exp file ##import exp file
out_dir<-paste(gsub("/$","",opt$out_dir),"/",sep="") out_dir<-paste(gsub("/$","",opt$out_dir),"/",sep="")
logexpr<-fread(opt$input,header=T,stringsAsFactors=F,row.names=1,check.names=F,data.table=F)
logexpr<-read.table(opt$input,header=T,stringsAsFactors=F,row.names=1,check.names=F)


#check exp file is log scale #check exp file is log scale
if(max(logexpr[,1])-min(logexpr[,1])>100){ if(max(logexpr[,1])-min(logexpr[,1])>100){

+ 1
- 2
RNAseq_4_pwDEG.R Ver arquivo

# choppy report script like : @scatter-plot(dataFile='/mnt/c/Users/YY/Documents/working/choppy_report/data/zhanggroup_P1-6vsP7-13_choppy_scatterplot_degs.rds', dataType='rds', xAxis='log2FC', xTitle="log2FC",yAxis='log10p',yTitle="-log10 (p)") # choppy report script like : @scatter-plot(dataFile='/mnt/c/Users/YY/Documents/working/choppy_report/data/zhanggroup_P1-6vsP7-13_choppy_scatterplot_degs.rds', dataType='rds', xAxis='log2FC', xTitle="log2FC",yAxis='log10p',yTitle="-log10 (p)")


suppressPackageStartupMessages(library("optparse")) suppressPackageStartupMessages(library("optparse"))
suppressPackageStartupMessages(library("data.table"))


# specify our desired options in a list # specify our desired options in a list
# by default OptionParser will add an help option equivalent to # by default OptionParser will add an help option equivalent to


##import files ##import files
out_dir<-paste(gsub("/$","",opt$out_dir),"/",sep="") out_dir<-paste(gsub("/$","",opt$out_dir),"/",sep="")
logexpr<-fread(opt$input,header=T,stringsAsFactors=F,row.names=1,check.names=F,data.table=F)
logexpr<-read.table(opt$input,header=T,stringsAsFactors=F,row.names=1,check.names=F)


#check exp file is log scale #check exp file is log scale
if(max(logexpr[,1])-min(logexpr[,1])>100){ if(max(logexpr[,1])-min(logexpr[,1])>100){

+ 1
- 2
RNAseq_5_pwGSEA.R Ver arquivo



suppressPackageStartupMessages(library("optparse")) suppressPackageStartupMessages(library("optparse"))
suppressPackageStartupMessages(library("fgsea")) suppressPackageStartupMessages(library("fgsea"))
suppressPackageStartupMessages(library("data.table"))


# specify our desired options in a list # specify our desired options in a list
# by default OptionParser will add an help option equivalent to # by default OptionParser will add an help option equivalent to


##import file ##import file
out_dir<-paste(gsub("/$","",opt$out_dir),"/",sep="") out_dir<-paste(gsub("/$","",opt$out_dir),"/",sep="")
logexpr<-fread(opt$input,header=T,stringsAsFactors=F,row.names=1,check.names=F,data.table=F)
logexpr<-read.table(opt$input,header=T,stringsAsFactors=F,row.names=1,check.names=F)


#check exp file is log scale #check exp file is log scale
if(max(logexpr[,1])-min(logexpr[,1])>100){ if(max(logexpr[,1])-min(logexpr[,1])>100){

+ 28
- 8
RNAseq_6_enrichfunc.R Ver arquivo

#!/usr/bin/env Rscript #!/usr/bin/env Rscript
###Copyright 2019 Ying Yu from Fudan-PGx group ###Copyright 2019 Ying Yu from Fudan-PGx group
# example: # example:
# Rscript RNAseq_6_enrichfunc.R -o /home/yuying/rnaseqreport_test -i ballgown_geneexp_log2fpkm_floor0p01_c3r58395_2019-04-29.txt -g group1.txt -p organoid
# Rscript RNAseq_6_enrichfunc.R -i rnaseq_degs_acrossgroups.csv


suppressPackageStartupMessages(library("optparse")) suppressPackageStartupMessages(library("optparse"))
suppressPackageStartupMessages(library("clusterProfiler")) suppressPackageStartupMessages(library("clusterProfiler"))
stop("At least one argument must be supplied (input file).", call.=FALSE) stop("At least one argument must be supplied (input file).", call.=FALSE)
} }


message("Need to connected to the Internet.")

##import file ##import file
out_dir<-paste(gsub("/$","",opt$out_dir),"/",sep="") out_dir<-paste(gsub("/$","",opt$out_dir),"/",sep="")
gene<-read.csv(opt$input,header=T,stringsAsFactors=F) gene<-read.csv(opt$input,header=T,stringsAsFactors=F)



########################## ##########################
#########ID convert####### #########ID convert#######
########################## ##########################
if(length(grep("ID_convert_table.rds",dir()))>0){


message("Begin ID conversion.")

if(length(grep("ID_convert_table.rds",dir()))>0){
idconvert<-readRDS("ID_convert_table.rds") idconvert<-readRDS("ID_convert_table.rds")
}else{ }else{
stop("Cannot find ID_convert_table.rds in the working folder. Exit!", call.=FALSE) stop("Cannot find ID_convert_table.rds in the working folder. Exit!", call.=FALSE)
gene$EntrezID<-gene[,1] gene$EntrezID<-gene[,1]
} }


message("Finish ID conversion.")

########################## ##########################
#########Enrich GO####### #########Enrich GO#######
########################## ##########################
g1<-g1[!g1==""] g1<-g1[!g1==""]
#conduct enrichment #conduct enrichment


message("Contucting enrichment analysis on GO terms...")
ego<-data.frame(enrichGO(g1, 'org.Hs.eg.db', ont = 'ALL', pvalueCutoff = opt$pvalueCutoff, pAdjustMethod = opt$pAdjustMethod, qvalueCutoff = opt$qvalueCutoff)) ego<-data.frame(enrichGO(g1, 'org.Hs.eg.db', ont = 'ALL', pvalueCutoff = opt$pvalueCutoff, pAdjustMethod = opt$pAdjustMethod, qvalueCutoff = opt$qvalueCutoff))

message("Contucting enrichment analysis on KEGG pathways...")
ekg<- data.frame( enrichKEGG(g1, organism = "hsa", keyType = "kegg", pvalueCutoff = opt$pvalueCutoff, pAdjustMethod = opt$pAdjustMethod, qvalueCutoff = opt$qvalueCutoff)) ekg<- data.frame( enrichKEGG(g1, organism = "hsa", keyType = "kegg", pvalueCutoff = opt$pvalueCutoff, pAdjustMethod = opt$pAdjustMethod, qvalueCutoff = opt$qvalueCutoff))
#modify output #modify output
} }


}else{ }else{

for (i in 1:length(groupn)){ for (i in 1:length(groupn)){

message(paste("Group ", groupn[i],sep=""))

g1<-gene$EntrezID[gene[,2]==groupn[i]] g1<-gene$EntrezID[gene[,2]==groupn[i]]
g1<-g1[!g1==""] g1<-g1[!g1==""]
#conduct enrichment #conduct enrichment


message("Contucting enrichment analysis on GO terms...")
ego<-data.frame(enrichGO(g1, 'org.Hs.eg.db', ont = 'ALL', pvalueCutoff = opt$pvalueCutoff, pAdjustMethod = opt$pAdjustMethod, qvalueCutoff = opt$qvalueCutoff)) ego<-data.frame(enrichGO(g1, 'org.Hs.eg.db', ont = 'ALL', pvalueCutoff = opt$pvalueCutoff, pAdjustMethod = opt$pAdjustMethod, qvalueCutoff = opt$qvalueCutoff))


message("Contucting enrichment analysis on KEGG pathways...")
ekg<- data.frame( enrichKEGG(g1, organism = "hsa", keyType = "kegg", pvalueCutoff = opt$pvalueCutoff, pAdjustMethod = opt$pAdjustMethod, qvalueCutoff = opt$qvalueCutoff)) ekg<- data.frame( enrichKEGG(g1, organism = "hsa", keyType = "kegg", pvalueCutoff = opt$pvalueCutoff, pAdjustMethod = opt$pAdjustMethod, qvalueCutoff = opt$qvalueCutoff))


if(!nrow(ego)==0){ if(!nrow(ego)==0){
ego1<-cbind(groupn[i],ego) ego1<-cbind(groupn[i],ego)
colnames(ego1)[1]<-c("versus") colnames(ego1)[1]<-c("versus")
egoall<-rbind(egoall,ego1) egoall<-rbind(egoall,ego1)
message(paste(nrow(ego),"significant GO term(s) is(are) identified."))
}else{
message("No significant GO term is identified.")
} }


if(!nrow(ekg)==0){ if(!nrow(ekg)==0){
ekg1<-cbind(groupn[i],ekg) ekg1<-cbind(groupn[i],ekg)
colnames(ekg1)[1]<-c("versus") colnames(ekg1)[1]<-c("versus")
ekeggall<-rbind(ekeggall,ekg1) ekeggall<-rbind(ekeggall,ekg1)
message(paste(nrow(ekg),"significant KEGG pathway(s) is(are) identified."))
}else{
message("No significant KEGG pathway is identified.")
} }
} }
} }
message("Wrinting output...")


#write output #write output
if(nrow(egoall)==0){ if(nrow(egoall)==0){
message("No significant GO term is identified.")
message("No significant GO term is identified across all tested groups.")
}else{ }else{
message(paste(nrow(egoall),"significant GO term(s) is(are) identified."))
message(paste(nrow(egoall),"significant GO term(s) is(are) identified across all tested groups."))
rownames(egoall)<-c(1:nrow(egoall)) rownames(egoall)<-c(1:nrow(egoall))
egoall$pvalue<-signif(egoall$pvalue,4) egoall$pvalue<-signif(egoall$pvalue,4)
egoall$p.adjust<-signif(egoall$p.adjust,4) egoall$p.adjust<-signif(egoall$p.adjust,4)
} }


if(nrow(ekeggall)==0){ if(nrow(ekeggall)==0){
message("No significant KEGG pathway is identified.")
message("No significant KEGG pathway is identified across all tested groups.")
}else{ }else{
message(paste(nrow(ekeggall),"significant KEGG pathway(s) is(are) identified."))
message(paste(nrow(ekeggall),"significant KEGG pathway(s) is(are) identified across all tested groups."))
rownames(ekeggall)<-c(1:nrow(ekeggall)) rownames(ekeggall)<-c(1:nrow(ekeggall))
ekeggall$pvalue<-signif(ekeggall$pvalue,4) ekeggall$pvalue<-signif(ekeggall$pvalue,4)
ekeggall$p.adjust<-signif(ekeggall$p.adjust,4) ekeggall$p.adjust<-signif(ekeggall$p.adjust,4)

Carregando…
Cancelar
Salvar