Commit cf756fbb authored by Claire Hoede's avatar Claire Hoede
Browse files

doc

parent 4b1694f0
##NAME = "GOBarplot.R"
##SYNOPSIS = "GOBarplot.R |-f "file1,file2..." --names "fileName1,fileName2..." --fileFormat "topGO" or "twoColumns" -o <results_path>"
##EXAMPLE = "Rscript --vanilla GOBarplot.R -f "./data/file1,./data/file2" --names "fileName1,fileName2" --fileFormat "topGO" -o "./results""
##DATE = "03/2016"
##AUTHORS = "Gaëlle Lefort"
##KEYWORDS = "RNAseq gene ontology barplot"
##DESCRIPTION = "GOEnrichment.R carries out a barplot to compare gene ontology between multiple set of files."
############################# Enrichment analysis ##############################
################################################################################
......@@ -43,8 +52,7 @@ option_list = list(
metavar = "character")
);
opt_parser = OptionParser(usage="Perform an enrichment analysis for
Gene Ontology (GO)", option_list = option_list);
opt_parser = OptionParser(usage="Carries out a barplot to compare gene ontology between multiple set of files", option_list = option_list);
opt = parse_args(opt_parser);
##############
......
##NAME = "GOEnrichment.R"
##SYNOPSIS = "GOEnrichment.R |-f <raw_data_path>/<file_name>.csv --fileFormat "topGO" or "twoColumns" --interest <interest_data_path>/<interest_file_name>.csv -o <results_path> --test "fisher" or "ks" --algorithm "classic", "elim" or "weight" --paramAlgo "bonferroni", "BH", 0.01, 0.05, "ratio" or "log" --alpha 0.05 --target "contigs", "gene"..."
##EXAMPLE = "Rscript --vanilla GOEnrichment.R --file "./data/topGO.csv" --fileFormat "topGO" --interest "./data/gene.txt" --out "./results/" --test "fisher" --algorithm "elim" --paramAlgo 0.01 --alpha 0.05 --target "contigs""
##DATE = "03/2016"
##AUTHORS = "Gaëlle Lefort"
##KEYWORDS = "RNAseq GO enrichment"
##DESCRIPTION = "GOEnrichment.R perform an enrichment analysis for Gene Ontology (GO)."
############################# Enrichment analysis ##############################
################################################################################
......@@ -10,7 +19,7 @@ packages <- c("optparse", # to read arguments from a command line
for(package in packages){
# if package is installed locally, load
if (!(package %in% rownames(installed.packages()))) {
install.packages(package, repos="http://cran.univ-paris1.fr")
install.packages(package)
}
do.call('library', list(package))
}
......@@ -18,7 +27,7 @@ for(package in packages){
#Bioconductor package
if (!("topGO" %in% rownames(installed.packages()))) {
source("http://www.bioconductor.org/biocLite.R")
biocLite("topGO")
biocLite("topGO", suppressUpdates = TRUE, suppressAutoUpdate = TRUE, ask = FALSE)
}
library(topGO) # GO enrichment
......@@ -80,9 +89,9 @@ opt = parse_args(opt_parser);
#opt$out <- XXX # for example "C:/My documents/results"
#opt$test <- XXX # "fisher" or "KS"
#opt$algorithm <- XXX # ('classic', 'elim' or 'weight')
#opt$paramAlgo <- XXX # ('bonferroni' or 'BH')
#opt$paramAlgo <- XXX # ('bonferroni' or 'BH' for classic, 0.01 for elim and 'ratio' or 'log' for weight)
#opt$alpha <- 0.05 # for example 0.05
#opt$target <- "contigs" # for example contigs
#opt$target <- "contigs" # for example contigs, gene...
# table with genes and GO, genes of interest, test and algorithm are needed to
......@@ -114,6 +123,34 @@ if(is.null(opt$paramAlgo)){
}
}
if(opt$algorithm == "classic" & !(opt$paramAlgo == "bonferroni" | opt$paramAlgo == "BH")){
stop("paramAlgo need to be equals to 'bonferroni' or 'BH'\n",
call. = FALSE)
}
if(opt$algorithm == "classic" & !(opt$paramAlgo == "bonferroni" | opt$paramAlgo == "BH")){
stop("paramAlgo need to be equals to 'bonferroni' or 'BH'\n",
call. = FALSE)
}
if(opt$algorithm == "elim"){
opt$paramAlgo <- as.numeric(opt$paramAlgo)
if(is.na(opt$paramAlgo)){
stop("paramAlgo need to be a number\n",
call. = FALSE)
}
if(opt$paramAlgo > 1){
stop("paramAlgo need to be inferior to 1\n",
call. = FALSE)
}
}
if(opt$algorithm == "weight" & !(opt$paramAlgo == "ratio" | opt$paramAlgo == "log")){
stop("paramAlgo need to be equals to 'ratio' or 'log'\n",
call. = FALSE)
}
#####################################################
### ---------------------Input data and preprocessing
......@@ -299,10 +336,10 @@ for(ontology in c("BP", "MF", "CC")){
resultTest@score <- p.adjust(resultTest@score, method = opt$paramAlgo)
} else if (opt$algorithm == "elim"){
resultTest <- runTest(myGOdata, algorithm = opt$algorithm, statistic = opt$test,
cutOff = as.numeric(opt$cutOff))
cutOff = as.numeric(opt$paramAlgo))
} else if (opt$algorithm == "weight"){
resultTest <- runTest(myGOdata, algorithm = opt$algorithm, statistic = opt$test,
sigRatio = opt$weightFunc)
sigRatio = opt$paramAlgo)
}
sigRes <- resultTest@score[resultTest@score <= opt$alpha]
......@@ -328,7 +365,9 @@ for(ontology in c("BP", "MF", "CC")){
}
names(GOgeneSig)[4] <- opt$target
if(!is.null(GOgeneSig)){
names(GOgeneSig)[4] <- opt$target
}
write.table(GOgeneSig, file = normalizePath(file.path(opt$out,
paste0("GOgeneSig.csv")),
mustWork = FALSE), sep = "\t",
......@@ -342,7 +381,7 @@ write.table(unique(GOgeneSig[,c("ontology", "GO", "GODef", "pval")]),
## JSON
stat <- list("notInTheAnalysis" = ifelse(!is.na(notInAnalysis[1]), notInAnalysis, "none"))
stat <- list("notInTheAnalysis" = ifelse(!is.na(notInAnalysis[1]), as.character(notInAnalysis), "none"))
write(gsub(" ", "", toJSON(list(stat=stat), collapse = "")),
file = normalizePath(file.path(opt$out, "results.json"),
......
##NAME = "Normalization.R"
##SYNOPSIS = "Normalization.R |-f <raw_data_path>/<file_name>.csv -o <results_path>"
##EXAMPLE = "Rscript --vanilla Normalization.R --file './data/count_table.csv' --out './results/'"
##DATE = "03/2016"
##AUTHORS = "Gaëlle Lefort"
##KEYWORDS = "RNAseq normalization"
##DESCRIPTION = "Normalization.R imports data, converts them into a DGEList object (edgeR), does all normalization methods and produces diagnostic plots."
################################ Normalization #################################
################################################################################
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment