Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update transformAssay with pseudocount TRUE/FALSE option #449

Merged
merged 6 commits into from
Sep 23, 2023

Conversation

RiboRings
Copy link
Member

Hi!

This PR is meant to simplify pseudocount selection for transformations that need a pseudocount, as discussed in this OMA issue.

The option TRUE of transformAssay sets pseudocount to smallest positive value of assay, whereas FALSE sets it to 0.

@RiboRings
Copy link
Member Author

Examples:

When negative values are present but pseudocount = TRUE, error arises because pseudocount should be set manually.

data("GlobalPatterns", package = "mia")
tse <- GlobalPatterns

assay(tse, "neg_counts") <- assay(tse, "counts") - 2

tse <- transformAssay(tse,
                      method = "relabundance",
                      assay.type = "neg_counts",
                      pseudocount = TRUE)

# Error: The assay contains some negative values. 'pseudocount' must be specified manually.

tse <- transformAssay(tse,
                      method = "relabundance",
                      assay.type = "neg_counts",
                      pseudocount = 4)

# Warning message:
# The assay contains some negative values. Applying a pseudocount may produce meaningless data.

When pseudocount = TRUE, applied value is returned as message

tse <- transformAssay(tse,
                      method = "relabundance",
                      pseudocount = TRUE)

# A pseudocount of 1 was applied.

Warning when only positive values but pseudocount = TRUE or positive number

tse <- transformAssay(tse,
                      method = "clr",
                      assay.type = "relabundance",
                      pseudocount = TRUE)

# Warning message:
# The assay contains only positive values. Applying a pseudocount is not necessary.

When negative values present but pseudocount = 0, FALSE or TRUE

tse <- transformAssay(tse,
                      method = "log10",
                      assay.type = "clr",
                      pseudocount = FALSE)

# Error: The assay contains negative values and log10 transformation is being applied without
# pseudocount.`pseudocount` must be specified manually.

R/transformCounts.R Outdated Show resolved Hide resolved
@RiboRings RiboRings merged commit 913dff9 into master Sep 23, 2023
@RiboRings RiboRings deleted the pseudocount_default branch September 23, 2023 09:18
Copy link
Contributor

@TuomasBorman TuomasBorman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants