Skip to content

cmd4: curatedMetagenomicData function prints a huge list of species to the console when dryrun = FALSE #331

Description

@lwaldron

Description

When calling curatedMetagenomicData with dryrun = FALSE and rownames = "short", the function prints a massive list of taxa (over 1,800 lines) directly to the console instead of executing silently. This occurs when it checks for and drops taxa without taxonomy information.

Reproducible Example

library(curatedMetagenomicData)

# cMD version: 4.0.1
packageVersion("curatedMetagenomicData")
#> [1] ‘4.0.1’

# This command should execute silently, but it floods the console with output
re <- curatedMetagenomicData("AsnicarF_2017.relative_abundance", dryrun = FALSE, rownames = "short")

Example Output

dropping rows without taxonomy info:
$`AsnicarF_2017.relative_abundance`
  k__Archaea|p__Euryarchaeota|c__Methanobacteria|o__Methanobacteriales|f__Methanobacteriaceae|g__Methanobrevibacter|s__Methanobrevibacter_smithii
  k__Archaea|p__Euryarchaeota|c__Methanobacteria|o__Methanobacteriales|f__Methanobacteriaceae|g__Methanobrevibacter|s__Methanobrevibacter_smithii|t__SGB346
  k__Archaea|p__Euryarchaeota|c__Methanobacteria|o__Methanobacteriales|f__Methanobacteriaceae|g__Methanosphaera|s__Methanosphaera_stadtmanae
  k__Archaea|p__Euryarchaeota|c__Methanobacteria|o__Methanobacteriales|f__Methanobacteriaceae|g__Methanosphaera|s__Methanosphaera_stadtmanae|t__SGB353
...
  <truncated: ~1,800 additional lines>
...
  k__Eukaryota|p__Eukaryota_unclassified|c__Bigyra|o__Opalinata|f__Blastocystidae|g__Blastocystis|s__Blastocystis_sp_subtype_1|t__EUK944036

Expected Behavior

The curatedMetagenomicData function should execute without flooding the console. When it drops rows, it should output a concise message.

Recommended Fix

In R/cmd4.R (around line 267), the msg construction uses paste0 with collapse = "\n", which dumps the entire drop_rows vector to the screen:

            msg <- paste0(
                msg, paste0("  ", drop_rows, collapse = "\n"), "\n"
            )

The recommended fix is to either truncate this list (e.g., printing only the first 5 elements followed by "... and N more") or simply print the count of dropped rows.

Example fix using truncation:

            max_print <- 5
            to_print <- head(drop_rows, max_print)
            msg <- paste0(msg, paste0("  ", to_print, collapse = "\n"))
            if (length(drop_rows) > max_print) {
                msg <- paste0(msg, "\n  ... and ", length(drop_rows) - max_print, " more")
            }
            msg <- paste0(msg, "\n")

Metadata

Metadata

Assignees

Labels

cmd4Affects only cmd4, and should be fixed before release of cmd4.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions