Skip to content

Commit

Permalink
removed excessive loop for scree plot, set param to default true
Browse files Browse the repository at this point in the history
  • Loading branch information
WackerO committed Nov 9, 2023
1 parent c68ded1 commit 9e1f716
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
35 changes: 17 additions & 18 deletions assets/differentialabundance_report.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down Expand Up @@ -546,32 +545,32 @@ 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
}
}
}
```

```{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")
}
```

Expand Down
2 changes: 1 addition & 1 deletion nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion nextflow_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@
},
"report_scree": {
"type": "boolean",
"default": "false",
"default": "true",
"description": "Whether to generate a scree plot in the report"
}
},
Expand Down

0 comments on commit 9e1f716

Please sign in to comment.