Commit 5489a1ec authored by Leon-Charles Tranchevent's avatar Leon-Charles Tranchevent
Browse files

Linted code.

parent 8918e9c1
......@@ -52,14 +52,14 @@ collapser <- function(x) {
# ================================================================================================
# We do all datasets one by one.
for (i in seq_len(length(config$datasets))) {
# We get the dataset details.
dataset <- config$datasets[[i]]
dataset_name <- dataset$dataset_name
# We run limma on the current dataset (if necessary).
if (selected_dataset_name == "" || selected_dataset_name == dataset_name) {
# We load the data (clinical and preproccesed data).
pheno_data_fn <- paste0(dataset_name, "_clinical_clean.tsv")
pheno_data <- Biobase::pData(ArrayUtils::load_clinical_data(input_data_dir,
......@@ -71,12 +71,12 @@ for (i in seq_len(length(config$datasets))) {
sep = "."))
exp_data_fn <- paste0(input_data_dir, dataset_name, "_normalized_clean.tsv")
exp_eset <- ArrayUtils::read_eset(exp_data_fn)
# Annotate the eset with gene information for better outputs.
# First, we collect raw the gene annotations and we have two options
# either from the Bioconductor package or from the processed GPL file.
platform_config <- get_platform(config, dataset$array_type)
# First, from a bioconductor package (usual case).
gene_annots_raw <- NULL
if (platform_config$library_name != "NA") {
......@@ -84,7 +84,7 @@ for (i in seq_len(length(config$datasets))) {
rownames(exp_eset))
} else {
# TODO: here read instead the sorted GPL file for special case.
gpl_annot_folder <- paste0(raw_data_dir, "/Platforms/")
gpl_annot_folder <- paste0(raw_data_dir, "Platforms/")
gpl_annot_filename <- paste0(platform_config$geo_name, "_gene_annots.tsv")
gene_annots_raw <- ArrayUtils::get_gene_annots_from_file(gpl_annot_folder,
gpl_annot_filename,
......@@ -98,7 +98,7 @@ for (i in seq_len(length(config$datasets))) {
ungroup -> gene_annots
gene_annots <- gene_annots[order(match(gene_annots$PROBEID, rownames(exp_eset))), ]
message(paste0("[", Sys.time(), "][", dataset_name, "] Gene annotations ready."))
# We only update the eset when the probe ids do match (otherwise, we issue a warning).
if (all(gene_annots$PROBEID == rownames(exp_eset))) {
gene_annots_asdf <- new("AnnotatedDataFrame",
......@@ -110,17 +110,17 @@ for (i in seq_len(length(config$datasets))) {
message(paste0("[", Sys.time(), "] Incorrect annotations for ", dataset_name, "."))
}
message(paste0("[", Sys.time(), "][", dataset_name, "] ExpressionSet updated."))
# Additional QC: plot the MDS to check again for outliers.
mds_filename <- paste0(output_data_dir, dataset_name, "_mdsplot.png")
png(mds_filename)
limma::plotMDS(exp_eset, labels = NULL, pch = 19)
dev.off()
message(paste0("[", Sys.time(), "][", dataset_name, "] MDS plot created."))
# Loop over Limma analyses
# Loop over Limma analyses.
for (j in seq_len(length(config$limma_analyses))) {
# We extract the Limma parameters.
limma_parameters <- config$limma_analyses[[j]]
limma_is_factorial <- limma_parameters$factorial
......@@ -128,7 +128,7 @@ for (i in seq_len(length(config$datasets))) {
# We only do the factorial analyses when possible, this fails otherwise.
# For instance, when there is no female PD patients (GSE7307).
if ((!limma_is_factorial) | (dataset$suitable_for_factorial_analysis == "TRUE")) {
if (!limma_is_factorial | dataset$suitable_for_factorial_analysis == "TRUE") { # nolint
# We use a block_key and cofactor_name if necessary (that is when we have
# paired samples).
if (dataset$has_paired_samples) {
......@@ -141,7 +141,7 @@ for (i in seq_len(length(config$datasets))) {
fit <- ArrayUtils::run_limma(pheno_data, exp_eset, limma_parameters)
}
message(paste0("[", Sys.time(), "][", dataset_name, "][", j, "] Limma fit done."))
# We loop over the coefficients we want to analyse for that Limma analysis.
for (k in seq_len(length(limma_coeff_names))) {
ArrayUtils::extract_DEGs(fit, limma_coeff_names, k, output_data_dir, dataset_name)
......
Supports Markdown
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