Skip to content

Commit 6d0c0fa

Browse files
authored
Merge pull request #203 from nasa/DEV_Metagenomics_ppl_updates_260622
Minor fixes to metagenomics pipeline docs
2 parents ff9a273 + 6e1dcba commit 6d0c0fa

3 files changed

Lines changed: 149 additions & 68 deletions

File tree

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

Lines changed: 5 additions & 5 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

@@ -3236,7 +3236,7 @@ humann_renorm_table -o Gene-families-KO-cpm_GLmetagenomics.tsv --update-snames
32363236
#### 20g. Combine MetaPhlan Taxonomy Tables
32373237

32383238
```bash
3239-
merge_metaphlan_tables.py *-humann3-out-dir/*_humann_temp/*_metaphlan_bugs_list.tsv > Metaphlan-taxonomy_GLmetagenomics.tsv
3239+
merge_metaphlan_tables.py *-humann3-out-dir/*_humann_temp/*_metaphlan_bugs_list.tsv > metaphlan-taxonomy_GLmetagenomics.tsv
32403240
```
32413241

32423242
**Parameter Definitions:**
@@ -3253,7 +3253,7 @@ merge_metaphlan_tables.py *-humann3-out-dir/*_humann_temp/*_metaphlan_bugs_list.
32533253

32543254
**Output data:**
32553255

3256-
- **Metaphlan-taxonomy_GLmetagenomics.tsv** (MetaPhlan estimated taxonomic relative abundances)
3256+
- **metaphlan-taxonomy_GLmetagenomics.tsv** (MetaPhlan estimated taxonomic relative abundances)
32573257

32583258
#### 20h. Create MetaPhlan Species Count Table
32593259

@@ -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: 68 additions & 31 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)
@@ -1765,7 +1800,10 @@ library(tidyr)
17651800
- `assay_suffix` - a character string specifying the GeneLab assay suffix (default: "_GLlblMetag")
17661801

17671802
**Output Data:**
1768-
- {output_prefix}_decontam_{species|KO}_table_GLlblMetag.tsv - decontaminated feature table file
1803+
- {output_prefix}_decontam_{species_table|table}_GLlblMetag.tsv - decontaminated feature table file, for
1804+
taxonomy classification methods the filename
1805+
includes the "species" keyword, other classification
1806+
methods omit the "species" keyword
17691807
- {output_prefix}_decontam_results_GLlblMetag.tsv - Decontam results file
17701808

17711809
**Returns:** dataframe, `decontaminated_table`, containing the decontaminated feature table
@@ -1891,9 +1929,8 @@ library(tidyr)
18911929
get_samples <- function(assembly_table_df, sample_names, end_col='species') {
18921930
# Get common samples
18931931
cols <- colnames(df)
1894-
index <- grep(end_col, cols)
18951932
start <- grep(end_col, cols) + 1
1896-
end <- (length(cols) - index)
1933+
end <- length(cols)
18971934
df_samples <- cols[start:end]
18981935
sample_names <- intersect(df_samples, sample_names)
18991936

@@ -3036,7 +3073,7 @@ feature_decontam(metadata_file = metadata_table,
30363073
assay_suffix = "_GLlblMetag")
30373074

30383075
make_heatmap(metadata_table_file = metadata_table,
3039-
feature_table_file = "Gene-families-uniref_decontam_species_table_GLlblMetag.tsv",
3076+
feature_table_file = "Gene-families-uniref_decontam_table_GLlblMetag.tsv",
30403077
samples_column="sample_id", group_column = "group",
30413078
output_prefix = "Gene-families-uniref_decontam",
30423079
assay_suffix = "_GLlblMetag",
@@ -3056,7 +3093,7 @@ feature_decontam(metadata_file = metadata_table,
30563093
assay_suffix = "_GLlblMetag")
30573094

30583095
make_heatmap(metadata_table_file = metadata_table,
3059-
feature_table_file = "Gene-families-KO_decontam_species_table_GLlblMetag.tsv",
3096+
feature_table_file = "Gene-families-KO_decontam_table_GLlblMetag.tsv",
30603097
samples_column="sample_id", group_column = "group",
30613098
output_prefix = "Gene-families-KO_decontam",
30623099
assay_suffix = "_GLlblMetag",
@@ -3076,7 +3113,7 @@ feature_decontam(metadata_file = metadata_table,
30763113
assay_suffix = "_GLlblMetag")
30773114

30783115
make_heatmap(metadata_table_file = metadata_table,
3079-
feature_table_file = "Pathway-abundances_decontam_species_table_GLlblMetag.tsv",
3116+
feature_table_file = "Pathway-abundances_decontam_table_GLlblMetag.tsv",
30803117
samples_column="sample_id", group_column = "group",
30813118
output_prefix = "Pathway-abundances_decontam",
30823119
assay_suffix = "_GLlblMetag",
@@ -3102,15 +3139,15 @@ make_heatmap(metadata_table_file = metadata_table,
31023139

31033140
**Output Data:**
31043141

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))
3142+
- **Gene-families-uniref_decontam_results_GLlblMetag.tsv** (decontam's result table for gene-family abundances, output from [feature_decontam()](#feature_decontam))
3143+
- **Gene-families-uniref_decontam_table_GLlblMetag.tsv** (decontaminated gene-family abundances table, output from [feature_decontam()](#feature_decontam))
3144+
- **Gene-families-uniref_decontam_heatmap_GLlblMetag.png** (heatmap of decontaminated gene-family abundances, output from [make_heatmap()](#make_heatmap))
3145+
- **Gene-families-KO_decontam_results_GLlblMetag.tsv** (decontam's result table KO term abundances, output from [feature_decontam()](#feature_decontam))
3146+
- **Gene-families-KO_decontam_table_GLlblMetag.tsv** (decontaminated KO term abundances table, output from [feature_decontam()](#feature_decontam))
3147+
- **Gene-families-KO_decontam_heatmap_GLlblMetag.png** (heatmap of decontaminated KO term abundances, output from [make_heatmap()](#make_heatmap))
31113148
- **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))
3149+
- **Pathway-abundances_decontam_table_GLlblMetag.tsv** (decontaminated species table, output from [feature_decontam()](#feature_decontam))
3150+
- **Pathway-abundances_decontam_heatmap_GLlblMetag.png** (barplot after filtering out contaminants, output from [make_heatmap()](#make_heatmap))
31143151

31153152
<br>
31163153

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

43654402
# Prepare metadata
@@ -4380,7 +4417,7 @@ decontaminated_table <- feature_decontam(metadata_file = metadata_table,
43804417
assay_suffix = "_GLlblMetag")
43814418

43824419
make_heatmap(metadata_table_file = metadata_table,
4383-
feature_table_file = "Combined-gene-level-KO-function_decontam_KO_table_GLlblMetag.tsv",
4420+
feature_table_file = "Combined-gene-level-KO-function_decontam_table_GLlblMetag.tsv",
43844421
samples_column = "sample_id", group_column = "group",
43854422
output_prefix = "Combined-gene-level-KO-function_decontam",
43864423
assay_suffix = "_GLlblMetag",
@@ -4405,7 +4442,7 @@ make_heatmap(metadata_table_file = metadata_table,
44054442
**Output Data:**
44064443

44074444
- **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))
4445+
- **Combined-gene-level-KO-function_decontam_table_GLlblMetag.tsv** (decontaminated gene-level KO functions table, output from [feature_decontam()](#feature_decontam))
44094446
- **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))
44104447
- **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))
44114448

@@ -4463,7 +4500,7 @@ make_heatmap(metadata_table_file = metadata_table,
44634500
**Input data:**
44644501
- assembly-summaries_GLlblMetag.tsv (table of assembly summary statistics, output from [Step 15b](#15b-summarize-assemblies))
44654502
- 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))
4503+
taxonomic classifications, output from [Step 23b](#23b-generate-contig-level-coverage-summary-tables))
44674504

44684505
**Output data:**
44694506
- Combined-contig-level-taxonomy_unfiltered_GLlblMetag.tsv (aggregated contig-level taxonomy table with samples in columns and species in rows)
@@ -4473,7 +4510,7 @@ make_heatmap(metadata_table_file = metadata_table,
44734510
#### 26h. Contig-level Feature Filtering
44744511

44754512
```R
4476-
feature_table_file <- "Combined-contig-level-taxonomy_GLlblMetag.tsv"
4513+
feature_table_file <- "Combined-contig-level-taxonomy_unfiltered_GLlblMetag.tsv"
44774514
metadata_table <- "/path/to/sample/metadata"
44784515
threshold <- 1000
44794516

@@ -4563,7 +4600,7 @@ make_heatmap(metadata_table_file = metadata_table,
45634600

45644601
**Input Data:**
45654602

4566-
- `Combined-contig-level-taxonomy_GLlblMetag.tsv`(aggregated contig taxonomy table with samples in columns and species in rows, from [Step 26g](#26g-contig-level-heatmaps))
4603+
- `Combined-contig-level-taxonomy_unfiltered_GLlblMetag.tsv`(aggregated contig taxonomy table with samples in columns and species in rows, from [Step 26g](#26g-contig-level-heatmaps))
45674604
- `/path/to/sample/metadata` (a file containing sample-wise metadata, mapping sample names to group metadata)
45684605

45694606
**Output Data:**

0 commit comments

Comments
 (0)