Skip to content

Commit

Permalink
Merge pull request #165 from MoTrPAC/develop
Browse files Browse the repository at this point in the history
v0.7.4: general improvements
  • Loading branch information
biodavidjm authored Oct 9, 2022
2 parents d320ae7 + d633139 commit 2ca2e6a
Show file tree
Hide file tree
Showing 74 changed files with 145 additions and 116 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: MotrpacBicQC
Type: Package
Title: QC/QA functions for the MoTrPAC community
Version: 0.7.3
Date: 2022-10-02
Version: 0.7.4
Date: 2022-10-09
Author: MoTrPAC Bioinformatics Center
Maintainer: David Jimenez-Morales <davidjm@stanford.edu>
Description: R Package for the analysis of MoTrPAC datasets.
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# MotrpacBicQC 0.7.4 (2022-10-09)

* Metabolomics plots: check if enough compounds to generate plots
* Update `assay_codes`: conventional assays code added (CONV)

# MotrpacBicQC 0.7.3 (2022-10-02)

* Adjustments to generate data releases (deal with pass1a/1c)
Expand Down
34 changes: 24 additions & 10 deletions R/metabolomics_plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ plot_basic_metabolomics_qc <- function(results,
# Density plots------

if(verbose) message(" - (p) Density distributions")
mu <- results_long %>% group_by(sample_id) %>% summarise(grp.mean=mean(intensity))
mu <- results_long %>% group_by(sample_id) %>% dplyr::summarise(grp.mean=mean(intensity))

den1 <- ggplot(data = results_long, aes(x = log2(intensity), color = sample_type)) +
geom_density(na.rm = TRUE) +
Expand Down Expand Up @@ -319,6 +319,20 @@ plot_basic_metabolomics_qc <- function(results,
out_plot_large <- file.path(normalizePath(out_qc_folder), paste0(output_prefix,"-qc-basic-large-plots.pdf"))
out_plot_summary <- file.path(normalizePath(out_qc_folder), paste0(output_prefix,"-qc-basic-summary-plots.pdf"))

.plotThePlots <- function(theplot, verbose = TRUE) {
tryCatch(
{
print(theplot)
},
error=function(cond) {
if(verbose) message(" - Plot cannot be printed")

},
warning=function(cond) {
if(verbose) message(paste(" - Print density plots cause warnings"))
})
}

if(printPDF){
if(sn > 800){
pdf(out_plot_large, width = 40, height = 8)
Expand All @@ -328,20 +342,20 @@ plot_basic_metabolomics_qc <- function(results,
pdf(out_plot_large, width = 14, height = 8)
}
}
print(psumint)
print(puid1)
print(piseio)
.plotThePlots(psumint)
.plotThePlots(puid1)
.plotThePlots(piseio)
gridExtra::grid.arrange(piseso, puid2, ncol = 1, heights = c(2, 1))
print(p_na_peprii)
.plotThePlots(p_na_peprii)
if(printPDF) garbage <- dev.off()

if(printPDF) pdf(out_plot_summary, width = 12, height = 6)
print(ptns)
.plotThePlots(ptns)
gridExtra::grid.arrange(ppids, pnids, ncol = 2)
print(den1)
print(den2)
print(den3)
if(!is.null(metametab)){print(pmzrt)}
.plotThePlots(den1)
.plotThePlots(den2)
.plotThePlots(den3)
if(!is.null(metametab)){.plotThePlots(pmzrt)}
if(printPDF) garbage <- dev.off()
}

Expand Down
61 changes: 33 additions & 28 deletions R/metabolomics_qc.R
Original file line number Diff line number Diff line change
Expand Up @@ -744,37 +744,42 @@ validate_metabolomics <- function(input_results_folder,
# This is targeted (no unnamed metabolites, no mz/rt plots)
results <- r_m_n[eresults_coln]
}

# results: check for negative values
results_long <- results %>% tidyr::pivot_longer(cols = -c(metabolite_name, id_type),
names_to = "sample_id",
values_to = "intensity")

results_long <- merge(m_s_n, results_long, by = c("sample_id"))
results_long$sample_id <- as.character(results_long$sample_id)
results_long$sample_id <- as.factor(results_long$sample_id)
results_long$sample_type <- as.factor(results_long$sample_type)
results_long <- results_long[which(results_long$intensity != 0),]
results_long <- results_long[!is.na(results_long$intensity),]
if(any(results_long$intensity < 0)){
message(" - (-) !!!!!!!!!!!!!!!!!!!!!!!!!!")
message(" - (-) NEGATIVE VALUES DETECTED!! ")
message(" - (-) !!!!!!!!!!!!!!!!!!!!!!!!!!")
results_long <- results_long[which(results_long$intensity > 0),]
ic <- ic + 1
# Ensure there are enough compounds to generate plots
if(dim(results)[1] > 1){
# results: check for negative values
results_long <- results %>% tidyr::pivot_longer(cols = -c(metabolite_name, id_type),
names_to = "sample_id",
values_to = "intensity")

results_long <- merge(m_s_n, results_long, by = c("sample_id"))
results_long$sample_id <- as.character(results_long$sample_id)
results_long$sample_id <- as.factor(results_long$sample_id)
results_long$sample_type <- as.factor(results_long$sample_type)
results_long <- results_long[which(results_long$intensity != 0),]
results_long <- results_long[!is.na(results_long$intensity),]
if(any(results_long$intensity < 0)){
message(" - (-) !!!!!!!!!!!!!!!!!!!!!!!!!!")
message(" - (-) NEGATIVE VALUES DETECTED!! ")
message(" - (-) !!!!!!!!!!!!!!!!!!!!!!!!!!")
results_long <- results_long[which(results_long$intensity > 0),]
ic <- ic + 1
}

plot_basic_metabolomics_qc(results = results,
results_long = results_long,
metametab = metametab,
out_qc_folder = out_qc_folder,
output_prefix = output_prefix,
printPDF = printPDF,
untargeted = untargeted,
verbose = verbose)

}else{
message(" (-) QC plots are not possible: not enough compounds")
}

plot_basic_metabolomics_qc(results = results,
results_long = results_long,
metametab = metametab,
out_qc_folder = out_qc_folder,
output_prefix = output_prefix,
printPDF = printPDF,
untargeted = untargeted,
verbose = verbose)

}else{
message("\n- (-) QC plots are not possible: critical datasets are missed")
if(verbose) message("\n- (-) QC plots are not possible: critical datasets are missed")
}

if(f_rmn & f_mmn){
Expand Down
Binary file modified data/assay_codes.rda
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/LICENSE-text.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/articles/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/articles/other_functions.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="generator" content="pandoc">
<meta name="date" content="2022-10-02">
<meta name="date" content="2022-10-09">
<title>MotrpacBicQC: Other Functions</title>
<script src="other_functions_files/header-attrs-2.16/header-attrs.js"></script><script src="other_functions_files/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1">
<link href="other_functions_files/bootstrap-3.3.7/css/bootstrap.min.css" rel="stylesheet">
Expand Down Expand Up @@ -123,7 +123,7 @@ <h1 class="title">MotrpacBicQC: Other Functions</h1>

<p class="authors">
</p>
<p class="date"><span class="glyphicon glyphicon-calendar"></span> 2022-10-02</p>
<p class="date"><span class="glyphicon glyphicon-calendar"></span> 2022-10-09</p>



Expand Down
4 changes: 2 additions & 2 deletions docs/articles/qc_metabolomics.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="generator" content="pandoc">
<meta name="date" content="2022-10-02">
<meta name="date" content="2022-10-09">
<title>MotrpacBicQC: Metabolomics QC</title>
<script src="qc_metabolomics_files/header-attrs-2.16/header-attrs.js"></script><script src="qc_metabolomics_files/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1">
<link href="qc_metabolomics_files/bootstrap-3.3.7/css/bootstrap.min.css" rel="stylesheet">
Expand Down Expand Up @@ -125,7 +125,7 @@ <h1 class="title">MotrpacBicQC: Metabolomics QC</h1>

<p class="authors">
</p>
<p class="date"><span class="glyphicon glyphicon-calendar"></span> 2022-10-02</p>
<p class="date"><span class="glyphicon glyphicon-calendar"></span> 2022-10-09</p>



Expand Down
4 changes: 2 additions & 2 deletions docs/articles/qc_proteomics.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="generator" content="pandoc">
<meta name="date" content="2022-10-02">
<meta name="date" content="2022-10-09">
<title>MotrpacBicQC: Proteomics QC</title>
<script src="qc_proteomics_files/header-attrs-2.16/header-attrs.js"></script><script src="qc_proteomics_files/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1">
<link href="qc_proteomics_files/bootstrap-3.3.7/css/bootstrap.min.css" rel="stylesheet">
Expand Down Expand Up @@ -125,7 +125,7 @@ <h1 class="title">MotrpacBicQC: Proteomics QC</h1>

<p class="authors">
</p>
<p class="date"><span class="glyphicon glyphicon-calendar"></span> 2022-10-02</p>
<p class="date"><span class="glyphicon glyphicon-calendar"></span> 2022-10-09</p>



Expand Down
6 changes: 3 additions & 3 deletions docs/authors.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion docs/news/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/notes_developers.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ articles:
other_functions: other_functions.html
qc_metabolomics: qc_metabolomics.html
qc_proteomics: qc_proteomics.html
last_built: 2022-10-03T05:32Z
last_built: 2022-10-09T07:07Z

2 changes: 1 addition & 1 deletion docs/reference/assay_abbr.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/assay_codes.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/assay_order.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/bic_animal_tissue_code.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/check_failedsamples.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/check_manifest_rawdata.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/check_metadata_metabolites.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/check_metadata_samples.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/check_ratio_proteomics.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/check_results.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2ca2e6a

Please sign in to comment.