Skip to content

Commit 31cd15e

Browse files
committed
Minor fixes to metagenomics pipeline docs
- Update software versions to match implemented workflow (NF_MetagenomeSeq 1.0.0-beta) - fix output file names in Filter Humann Output and Humann Feature decontamination steps - fix get_samples() function index bug - update run_decontam() and feature_decontam() functions - fix metadata parsing issue with true/false values prevalence column - simplify output file naming to match implemented workflow
1 parent ac3bcdb commit 31cd15e

3 files changed

Lines changed: 132 additions & 57 deletions

File tree

‎Metagenomics/Illumina/Pipeline_GL-DPPD-7107_Versions/GL-DPPD-7107-B.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ Software Updates and Changes:
202202
| samtools | 1.23.1 | [https://github.com/samtools/samtools#samtools](https://github.com/samtools/samtools#samtools) |
203203
| SPAdes | 4.2.0 | [https://github.com/ablab/spades](https://github.com/ablab/spades) |
204204
| R | 4.5.3 | [https://www.r-project.org](https://www.r-project.org) |
205-
| dplyr | 1.2.0 | [https://dplyr.tidyverse.org](https://dplyr.tidyverse.org) |
205+
| dplyr | 1.2.1 | [https://dplyr.tidyverse.org](https://dplyr.tidyverse.org) |
206206
| ggplot2 | 4.0.2 | [https://ggplot2.tidyverse.org](https://ggplot2.tidyverse.org) |
207207
| glue | 1.8.0 | [https://glue.tidyverse.org](https://glue.tidyverse.org) |
208208
| htmlwidgets | 1.6.4 | [http://www.htmlwidgets.org](http://www.htmlwidgets.org) |
@@ -1112,7 +1112,7 @@ library(tidyr)
11121112
cols <- colnames(df)
11131113
index <- grep(end_col, cols)
11141114
start <- grep(end_col, cols) + 1
1115-
end <- (length(cols) - index)
1115+
end <- length(cols)
11161116
df_samples <- cols[start:end]
11171117
sample_names <- intersect(df_samples, sample_names)
11181118

@@ -3496,7 +3496,7 @@ write_tsv(x = table2write, file = "Pathway-abundances_filtered_GLmetagenomics.ts
34963496
- Pathway-abundances_unfiltered_GLmetagenomics.tsv (pathway abundances normalized to copies-per-million, with cleaned headers)
34973497
- **Gene-families-KO_filtered_GLmetagenomics.tsv** (KO term abundances filtered for features with less than 500 CPM across samples)
34983498
- **Gene-families-uniref_filtered_GLmetagenomics.tsv** (gene-family abundances filtered for features with less than 500 CPM across samples)
3499-
- **Gene-families-KO_filtered_GLmetagenomics.tsv** (Pathway abundances filtered for features with less than 500 CPM across samples)
3499+
- **Pathway-abundances_filtered_GLmetagenomics.tsv** (Pathway abundances filtered for features with less than 500 CPM across samples)
35003500

35013501
#### 20l. Create Humann Function Heatmaps
35023502

‎Metagenomics/Low_Biomass/Pipeline_GL-DPPD-7116_Versions/GL-DPPD-7116.md‎

Lines changed: 62 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,13 @@ Barbara Novak (GeneLab Data Processing Lead)
171171
| MetaPhlAn | 4.1.0 | [https://github.com/biobakery/MetaPhlAn](https://github.com/biobakery/MetaPhlAn) |
172172
| Minimap2 | 2.30 | [https://github.com/lh3/minimap2](https://github.com/lh3/minimap2) |
173173
| MultiQC | 1.27.1 | [https://multiqc.info/](https://multiqc.info/) |
174-
| NanoPlot | 1.45.2 | [https://github.com/wdecoster/NanoPlot](https://github.com/wdecoster/NanoPlot) |
174+
| NanoPlot | 1.46.2 | [https://github.com/wdecoster/NanoPlot](https://github.com/wdecoster/NanoPlot) |
175175
| Porechop | 0.2.4 | [https://github.com/rrwick/Porechop](https://github.com/rrwick/Porechop) |
176176
| Prodigal | 2.6.3 | [https://github.com/hyattpd/Prodigal#prodigal](https://github.com/hyattpd/Prodigal#prodigal) |
177177
| samtools | 1.23.1 | [https://github.com/samtools/samtools#samtools](https://github.com/samtools/samtools#samtools) |
178178
| R | 4.5.3 | [https://www.r-project.org](https://www.r-project.org) |
179179
| decontam | 1.30.0 | [https://www.bioconductor.org/packages/release/bioc/html/decontam.html](https://www.bioconductor.org/packages/release/bioc/html/decontam.html) |
180-
| dplyr | 1.2.0 | [https://dplyr.tidyverse.org](https://dplyr.tidyverse.org) |
180+
| dplyr | 1.2.1 | [https://dplyr.tidyverse.org](https://dplyr.tidyverse.org) |
181181
| ggplot2 | 4.0.2 | [https://ggplot2.tidyverse.org](https://ggplot2.tidyverse.org) |
182182
| glue | 1.8.0 | [https://glue.tidyverse.org](https://glue.tidyverse.org) |
183183
| htmlwidgets | 1.6.4 | [http://www.htmlwidgets.org](http://www.htmlwidgets.org) |
@@ -1630,7 +1630,6 @@ library(tidyr)
16301630
)
16311631
)
16321632
sub_metadata[, freq_col] <- as.numeric(sub_metadata[, freq_col])
1633-
sub_metadata[, prev_col] <- tolower(sub_metadata[, prev_col])
16341633

16351634
}
16361635

@@ -1696,24 +1695,56 @@ library(tidyr)
16961695
feature_table <- feature_table[, -1] %>% as.matrix()
16971696

16981697
# Prepare metadata
1699-
metadata <- read_delim(metadata_file) %>% as.data.frame
1698+
metadata <- read_delim(metadata_file)
1699+
if (!is.null(prevalence_column) && prevalence_column %in% colnames(metadata)) {
1700+
metadata <- metadata %>%
1701+
mutate(!!prevalence_column := as.character(!!sym(prevalence_column)) %>%
1702+
tolower()) %>%
1703+
as.data.frame()
1704+
} else {
1705+
metadata <- metadata %>% as.data.frame()
1706+
}
17001707
row.names(metadata) <- metadata[, samples_column]
17011708

1709+
samples <- intersect(colnames(feature_table), rownames(metadata))
1710+
metadata <- metadata[samples, ]
1711+
feature_table <- feature_table[, samples]
1712+
1713+
if (classification_method == "gene-function") {
1714+
1715+
name <- "Combined-gene-level-KO-function"
1716+
1717+
} else if (classification_method == "gene-taxonomy") {
1718+
1719+
name <- "Combined-gene-level-taxonomy"
1720+
1721+
} else if (classification_method == "contig-taxonomy") {
1722+
1723+
name <- "Combined-contig-level-taxonomy"
1724+
1725+
} else {
1726+
1727+
name <- classification_method
1728+
1729+
}
1730+
17021731
# Run decontam
1703-
# Assign prev and freq column names to NULL if the values in the supplied columns aren't unique
1704-
if( length(unique(metadata[, prev_col])) == 1) prev_col <- NULL
1705-
if( length(unique(metadata[, freq_col])) == 1) freq_col <- NULL
1706-
contamdf <- run_decontam(feature_table, metadata, threshold, prev_col, freq_col, ntc_name)
1732+
# Assign prevalence and frequency_column column names to NULL if the values in the supplied columns aren't unique
1733+
if( length(unique(metadata[, prevalence_column])) == 1) prevalence_column <- NULL
1734+
if( length(unique(metadata[, frequency_column])) == 1) frequency_column <- NULL
1735+
contamdf <- run_decontam(feature_table, metadata, threshold, prevalence_column, frequency_column, ntc_name)
17071736

17081737
contamdf <- as.data.frame(contamdf) %>% rownames_to_column(feature_column)
17091738

17101739
type <- 'species'
17111740
if (classification_method == 'gene-function') { type <- "KO" }
17121741

17131742
# Write decontaminated feature table and decontam's primary results
1714-
outfile <- glue("{output_prefix}_decontam_results{assay_suffix}.tsv")
1743+
outfile <- glue("{output_prefix}{name}_decontam_results{assay_suffix}.tsv")
17151744
write_tsv(x = contamdf, file = outfile)
17161745

1746+
taxonomy_methods <- c("kaiju", "kraken2", "metaphlan", "gene-taxonomy", "contig-taxonomy")
1747+
17171748
# Get the list of contaminants identified by decontam
17181749
contaminants <- contamdf %>%
17191750
filter(contaminant == TRUE) %>%
@@ -1732,9 +1763,13 @@ library(tidyr)
17321763
negate = TRUE))
17331764

17341765
rownames(decontaminated_table) <- decontaminated_table[[feature_column]]
1735-
decontaminated_table <- decontaminated_table[,-1] %>% as.matrix
17361766

1737-
outfile <- glue("{output_prefix}_decontam_{type}_table{assay_suffix}.tsv")
1767+
# Add _species string to output file name if it is a taxonomy method
1768+
if (any(grep(pattern = classification_method, x = taxonomy_methods))) {
1769+
outfile <- glue("{output_prefix}{name}_decontam_species_table{assay_suffix}.tsv")
1770+
} else {
1771+
outfile <- glue("{output_prefix}{name}_decontam_table{assay_suffix}.tsv")
1772+
}
17381773
write_tsv(x = decontaminated_table, file = outfile)
17391774

17401775
return(decontaminated_table)
@@ -1891,9 +1926,8 @@ library(tidyr)
18911926
get_samples <- function(assembly_table_df, sample_names, end_col='species') {
18921927
# Get common samples
18931928
cols <- colnames(df)
1894-
index <- grep(end_col, cols)
18951929
start <- grep(end_col, cols) + 1
1896-
end <- (length(cols) - index)
1930+
end <- length(cols)
18971931
df_samples <- cols[start:end]
18981932
sample_names <- intersect(df_samples, sample_names)
18991933

@@ -3036,7 +3070,7 @@ feature_decontam(metadata_file = metadata_table,
30363070
assay_suffix = "_GLlblMetag")
30373071

30383072
make_heatmap(metadata_table_file = metadata_table,
3039-
feature_table_file = "Gene-families-uniref_decontam_species_table_GLlblMetag.tsv",
3073+
feature_table_file = "Gene-families-uniref_decontam_table_GLlblMetag.tsv",
30403074
samples_column="sample_id", group_column = "group",
30413075
output_prefix = "Gene-families-uniref_decontam",
30423076
assay_suffix = "_GLlblMetag",
@@ -3056,7 +3090,7 @@ feature_decontam(metadata_file = metadata_table,
30563090
assay_suffix = "_GLlblMetag")
30573091

30583092
make_heatmap(metadata_table_file = metadata_table,
3059-
feature_table_file = "Gene-families-KO_decontam_species_table_GLlblMetag.tsv",
3093+
feature_table_file = "Gene-families-KO_decontam_table_GLlblMetag.tsv",
30603094
samples_column="sample_id", group_column = "group",
30613095
output_prefix = "Gene-families-KO_decontam",
30623096
assay_suffix = "_GLlblMetag",
@@ -3076,7 +3110,7 @@ feature_decontam(metadata_file = metadata_table,
30763110
assay_suffix = "_GLlblMetag")
30773111

30783112
make_heatmap(metadata_table_file = metadata_table,
3079-
feature_table_file = "Pathway-abundances_decontam_species_table_GLlblMetag.tsv",
3113+
feature_table_file = "Pathway-abundances_decontam_table_GLlblMetag.tsv",
30803114
samples_column="sample_id", group_column = "group",
30813115
output_prefix = "Pathway-abundances_decontam",
30823116
assay_suffix = "_GLlblMetag",
@@ -3102,15 +3136,15 @@ make_heatmap(metadata_table_file = metadata_table,
31023136

31033137
**Output Data:**
31043138

3105-
- **Gene-family-uniref_decontam_results_GLlblMetag.tsv** (decontam's result table for gene-family abundances, output from [feature_decontam()](#feature_decontam))
3106-
- **Gene-family-uniref_decontam_species_table_GLlblMetag.tsv** (decontaminated gene-family abundances table, output from [feature_decontam()](#feature_decontam))
3107-
- **Gene-family-uniref_decontam_species_heatmap_GLlblMetag.png** (heatmap of decontaminated gene-family abundances, output from [make_heatmap()](#make_heatmap))
3108-
- **Gene-family-KO_decontam_results_GLlblMetag.tsv** (decontam's result table KO term abundances, output from [feature_decontam()](#feature_decontam))
3109-
- **Gene-family-KO_decontam_species_table_GLlblMetag.tsv** (decontaminated KO term abundances table, output from [feature_decontam()](#feature_decontam))
3110-
- **Gene-family-KO_decontam_species_heatmap_GLlblMetag.png** (heatmap of decontaminated KO term abundances, output from [make_heatmap()](#make_heatmap))
3139+
- **Gene-families-uniref_decontam_results_GLlblMetag.tsv** (decontam's result table for gene-family abundances, output from [feature_decontam()](#feature_decontam))
3140+
- **Gene-families-uniref_decontam_table_GLlblMetag.tsv** (decontaminated gene-family abundances table, output from [feature_decontam()](#feature_decontam))
3141+
- **Gene-families-uniref_decontam_heatmap_GLlblMetag.png** (heatmap of decontaminated gene-family abundances, output from [make_heatmap()](#make_heatmap))
3142+
- **Gene-families-KO_decontam_results_GLlblMetag.tsv** (decontam's result table KO term abundances, output from [feature_decontam()](#feature_decontam))
3143+
- **Gene-families-KO_decontam_table_GLlblMetag.tsv** (decontaminated KO term abundances table, output from [feature_decontam()](#feature_decontam))
3144+
- **Gene-families-KO_decontam_heatmap_GLlblMetag.png** (heatmap of decontaminated KO term abundances, output from [make_heatmap()](#make_heatmap))
31113145
- **Pathway-abundances_decontam_results_GLlblMetag.tsv** (decontam's result table, output from [feature_decontam()](#feature_decontam))
3112-
- **Pathway-abundances_decontam_species_table_GLlblMetag.tsv** (decontaminated species table, output from [feature_decontam()](#feature_decontam))
3113-
- **Pathway-abundances_decontam_species_heatmap_GLlblMetag.png** (barplot after filtering out contaminants, output from [make_heatmap()](#make_heatmap))
3146+
- **Pathway-abundances_decontam_table_GLlblMetag.tsv** (decontaminated species table, output from [feature_decontam()](#feature_decontam))
3147+
- **Pathway-abundances_decontam_heatmap_GLlblMetag.png** (barplot after filtering out contaminants, output from [make_heatmap()](#make_heatmap))
31143148

31153149
<br>
31163150

@@ -4359,7 +4393,7 @@ make_heatmap(metadata_table_file = metadata_table,
43594393
> Note: species_table and heatmaps are only generated if 1 or more contaminants were detected
43604394
43614395
```R
4362-
feature_table_file <- "genes-KO-functions_table.tsv"
4396+
feature_table_file <- "Combined-gene-level-KO-function_unfiltered_GLlblMetag.tsv"
43634397
metadata_table <- "/path/to/sample/metadata"
43644398

43654399
# Prepare metadata
@@ -4380,7 +4414,7 @@ decontaminated_table <- feature_decontam(metadata_file = metadata_table,
43804414
assay_suffix = "_GLlblMetag")
43814415

43824416
make_heatmap(metadata_table_file = metadata_table,
4383-
feature_table_file = "Combined-gene-level-KO-function_decontam_KO_table_GLlblMetag.tsv",
4417+
feature_table_file = "Combined-gene-level-KO-function_decontam_table_GLlblMetag.tsv",
43844418
samples_column = "sample_id", group_column = "group",
43854419
output_prefix = "Combined-gene-level-KO-function_decontam",
43864420
assay_suffix = "_GLlblMetag",
@@ -4405,7 +4439,7 @@ make_heatmap(metadata_table_file = metadata_table,
44054439
**Output Data:**
44064440

44074441
- **Combined-gene-level-KO-function_decontam_results_GLlblMetag.tsv** (decontam results table, output from [feature_decontam()](#feature_decontam))
4408-
- **Combined-gene-level-KO-function_decontam_KO_table_GLlblMetag.tsv** (decontaminated gene-level KO functions table, output from [feature_decontam()](#feature_decontam))
4442+
- **Combined-gene-level-KO-function_decontam_table_GLlblMetag.tsv** (decontaminated gene-level KO functions table, output from [feature_decontam()](#feature_decontam))
44094443
- **Combined-gene-level-KO-function_decontam_heatmap_GLlblMetag.png** (heatmap of all gene-level KO function assignments after filtering out contaminants, output from [make_heatmap()](#make_heatmap))
44104444
- **Combined-gene-level-KO-function_decontam_top_50_heatmap_GLlblMetag.png** (heatmap of the top 50 gene-level KO function assignments after filtering out contaminants, output from [make_heatmap()](#make_heatmap))
44114445

@@ -4463,7 +4497,7 @@ make_heatmap(metadata_table_file = metadata_table,
44634497
**Input data:**
44644498
- assembly-summaries_GLlblMetag.tsv (table of assembly summary statistics, output from [Step 15b](#15b-summarize-assemblies))
44654499
- Combined-contig-level-taxonomy-coverages-CPM_GLlblMetag.tsv (table with all samples combined based on contig-level
4466-
taxonomic classifications, output from [Step 22](#22-combine-contig-level-coverage-and-taxonomy-for-each-sample))
4500+
taxonomic classifications, output from [Step 23b](#23b-generate-contig-level-coverage-summary-tables))
44674501

44684502
**Output data:**
44694503
- Combined-contig-level-taxonomy_unfiltered_GLlblMetag.tsv (aggregated contig-level taxonomy table with samples in columns and species in rows)

0 commit comments

Comments
 (0)