From 9e1f716f33a2c76fecd6f225439d8862c14c07dd Mon Sep 17 00:00:00 2001 From: WackerO Date: Thu, 9 Nov 2023 13:01:39 +0100 Subject: [PATCH] removed excessive loop for scree plot, set param to default true --- assets/differentialabundance_report.Rmd | 35 ++++++++++++------------- nextflow.config | 2 +- nextflow_schema.json | 2 +- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/assets/differentialabundance_report.Rmd b/assets/differentialabundance_report.Rmd index 13446335..e8eb91b7 100644 --- a/assets/differentialabundance_report.Rmd +++ b/assets/differentialabundance_report.Rmd @@ -501,7 +501,6 @@ percentVar_list <- list() for (assay_type in rev(names(assay_data))){ pca_data <- pca_datas[[assay_type]] - percentVar_list[[assay_type]] <- list() for (iv in informative_variables){ cat(paste0("\n##### ", prettifyVariablename(assay_type), " (", iv, ")\n")) @@ -546,7 +545,9 @@ for (assay_type in rev(names(assay_data))){ print(htmltools::tagList(do.call("plotly_scatterplot", plot_args))) } - percentVar_list[[assay_type]][[iv]] <- percentVar + if (! assay_type %in% names(percentVar_list)){ + percentVar_list[[assay_type]] <- percentVar + } } } ``` @@ -554,24 +555,22 @@ for (assay_type in rev(names(assay_data))){ ```{r, echo=FALSE, results='asis', eval=params$report_scree} cat(paste0("\n#### Scree plot {.tabset}")) cat(paste0("\nThe following scree plot visualizes what percentage of total variation in the data can be explained by each of the principal components computed.\n")) +#iv <- informative_variables[1] for (assay_type in names(percentVar_list)) { - for (iv in names(percentVar_list[[assay_type]])) { - percentVarData <- data.frame(percentVar_list[[assay_type]][[iv]]) - colnames(percentVarData) <- c("var_explained") - percentVarData$PCA <- as.numeric(rownames(percentVarData)) - write.table(percentVarData, file=paste0("/home-link/iivow01/git/save_differentialabundance/error/", assay_type, "_", iv, "_varex.tsv"), quote=F, sep="\t") - cat(paste0("\n##### ", prettifyVariablename(assay_type), " (", iv, ")\n")) - print( - ggplot(percentVarData, aes(x=factor(PCA),y=var_explained, group=1)) + - theme_bw() + - geom_point(size=4) + - geom_line(linetype="dashed") + - xlab("PC") + - ylab("Percent variance explained") - ) - cat("\n") - } + percentVarData <- data.frame(percentVar_list[[assay_type]]) + colnames(percentVarData) <- c("var_explained") + percentVarData$PCA <- as.numeric(rownames(percentVarData)) + cat(paste0("\n##### ", prettifyVariablename(assay_type), "\n")) + print( + ggplot(percentVarData, aes(x=factor(PCA),y=var_explained, group=1)) + + theme_bw() + + geom_point(size=4) + + geom_line(linetype="dashed") + + xlab("PC") + + ylab("Percent variance explained") + ) + cat("\n") } ``` diff --git a/nextflow.config b/nextflow.config index 7a16b04a..665d8317 100644 --- a/nextflow.config +++ b/nextflow.config @@ -28,7 +28,7 @@ params { report_title = null report_author = null report_description = null - report_scree = false + report_scree = true // Sample sheet options observations_type = 'sample' diff --git a/nextflow_schema.json b/nextflow_schema.json index 9844bf54..8da8998a 100644 --- a/nextflow_schema.json +++ b/nextflow_schema.json @@ -955,7 +955,7 @@ }, "report_scree": { "type": "boolean", - "default": "false", + "default": "true", "description": "Whether to generate a scree plot in the report" } },