Skip to contents

Filter ASV abundance matrix and convert to 'taxmap' and 'phyloseq' objects

Usage

convert_asv_matrix_to_objs(
  analysis_setup,
  min_read_depth = 0,
  minimum_bootstrap = 0,
  save_outputs = FALSE
)

Arguments

analysis_setup

An object containing directory paths and data tables, produced by the prepare_reads function

min_read_depth

ASV filter parameter. If mean read depth of across all samples is less than this threshold, ASV will be filtered.

minimum_bootstrap

Set threshold for bootstrap support value for taxonomic assignments. Below designated minimum bootstrap threshold, taxonomic assignments will be set to N/A

save_outputs

Logical, indicating whether to save the resulting phyloseq and 'taxmap' objects. If TRUE, the objects will be saved; if FALSE, they will only be available in the global environment. Default is FALSE.

Value

ASV matrix converted to 'taxmap' object

Examples

# \donttest{
# Convert final matrix to 'taxmap' and phyloseq objects for downstream analysis steps
analysis_setup <- prepare_reads(
data_directory = system.file("extdata", package = "demulticoder"),
  output_directory = tempdir(),
  overwrite_existing = TRUE
)
#> Existing files found in the output directory. Overwriting existing files.
#> Rows: 2 Columns: 25
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> chr  (3): primer_name, forward, reverse
#> dbl (18): minCutadaptlength, maxN, maxEE_forward, maxEE_reverse, truncLen_fo...
#> lgl  (4): already_trimmed, count_all_samples, multithread, verbose
#> 
#>  Use `spec()` to retrieve the full column specification for this data.
#>  Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Rows: 2 Columns: 25
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> chr  (3): primer_name, forward, reverse
#> dbl (18): minCutadaptlength, maxN, maxEE_forward, maxEE_reverse, truncLen_fo...
#> lgl  (4): already_trimmed, count_all_samples, multithread, verbose
#> 
#>  Use `spec()` to retrieve the full column specification for this data.
#>  Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Rows: 4 Columns: 3
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> chr (3): sample_name, primer_name, organism
#> 
#>  Use `spec()` to retrieve the full column specification for this data.
#>  Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Creating output directory: /tmp/RtmpBJNmaI/demulticoder_run/prefiltered_sequences

cut_trim(
analysis_setup,
cutadapt_path="/usr/bin/cutadapt",
overwrite_existing = TRUE
)
#> Running cutadapt 3.5 for its sequence data

#> Running cutadapt 3.5 for rps10 sequence data

make_asv_abund_matrix(
analysis_setup,
overwrite_existing = TRUE
)
#> 80608 total bases in 307 reads from 2 samples will be used for learning the error rates.
#> Error rate plot for the  Forward  read of primer pair  its
#> Warning: log-10 transformation introduced infinite values.
#> Sample 1 - 163 reads in 84 unique sequences.
#> Sample 2 - 144 reads in 96 unique sequences.
#> 82114 total bases in 307 reads from 2 samples will be used for learning the error rates.
#> Error rate plot for the  Reverse  read of primer pair  its
#> Warning: log-10 transformation introduced infinite values.
#> Sample 1 - 163 reads in 128 unique sequences.
#> Sample 2 - 144 reads in 119 unique sequences.


#> 91897 total bases in 327 reads from 2 samples will be used for learning the error rates.
#> Error rate plot for the  Forward  read of primer pair  rps10
#> Warning: log-10 transformation introduced infinite values.
#> Sample 1 - 145 reads in 107 unique sequences.
#> Sample 2 - 182 reads in 133 unique sequences.
#> 91567 total bases in 327 reads from 2 samples will be used for learning the error rates.
#> Error rate plot for the  Reverse  read of primer pair  rps10
#> Warning: log-10 transformation introduced infinite values.
#> Sample 1 - 145 reads in 114 unique sequences.
#> Sample 2 - 182 reads in 170 unique sequences.


#> $its
#> [1] "/tmp/RtmpBJNmaI/demulticoder_run/asvabund_matrixDADA2_its.RData"
#> 
#> $rps10
#> [1] "/tmp/RtmpBJNmaI/demulticoder_run/asvabund_matrixDADA2_rps10.RData"
#> 
assign_tax(
analysis_setup,
asv_abund_matrix,
retrieve_files=FALSE,
overwrite_existing=TRUE
)
#> Tracking read counts:
#>   samplename_barcode input filtered denoisedF denoisedR merged nonchim
#> 1             S1_its   299      163       146       141    132     132
#> 2             S2_its   235      144       113        99     99      99
#> Tracking read counts:
#>   samplename_barcode input filtered denoisedF denoisedR merged nonchim
#> 1           S1_rps10   196      145       145       145    145     145
#> 2           S2_rps10   253      182       181       181    181     181
objs<-convert_asv_matrix_to_objs(
analysis_setup
)
#> Rows: 12 Columns: 5
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> chr (3): asv_id, sequence, dada2_tax
#> dbl (2): S1_its, S2_its
#> 
#>  Use `spec()` to retrieve the full column specification for this data.
#>  Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> For its dataset 
#> Taxmap object saved in: /tmp/RtmpBJNmaI/taxmap_obj_its.RData 
#> Phyloseq object saved in: /tmp/RtmpBJNmaI/phylo_obj_its.RData 
#> ASVs filtered by minimum read depth: 0 
#> For taxonomic assignments, if minimum bootstrap was set to: 0 assignments were set to 'Unsupported' 
#> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#> Rows: 5 Columns: 5
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> chr (3): asv_id, sequence, dada2_tax
#> dbl (2): S1_rps10, S2_rps10
#> 
#>  Use `spec()` to retrieve the full column specification for this data.
#>  Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> For rps10 dataset 
#> Taxmap object saved in: /tmp/RtmpBJNmaI/taxmap_obj_rps10.RData 
#> Phyloseq object saved in: /tmp/RtmpBJNmaI/phylo_obj_rps10.RData 
#> ASVs filtered by minimum read depth: 0 
#> For taxonomic assignments, if minimum bootstrap was set to: 0 assignments were set to 'Unsupported' 
#> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# }