Skip to content

Add Shannon diversity protocol - #53

Open
ohih8 wants to merge 1 commit into
waldronlab:mainfrom
ohih8:protocol/shannon-diversity
Open

ohih8 wants to merge 1 commit into
waldronlab:mainfrom
ohih8:protocol/shannon-diversity

Conversation

@ohih8

@ohih8 ohih8 commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Closes #50

Adds Shannon diversity protocol and two small tests for it. More tests should be added in the future, however these are the most important and it is probably a good idea to wait until the testing infrastructure is fully set up before generating a large amount of tests.
NOTE: This Protocol does not include rarefaction or sequencing depth-normalization as an intentional design choice by me to simplify the protocol. It can certainly be added if desired, however I wanted to keep the protocol concise.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ohih8
ohih8 requested a review from lwaldron as a code owner October 21, 2026 02:01

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@ohih8

ohih8 commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

@claude review

- **Input scale:** A required parameter, either `counts` or `proportions`.
- **Logarithm base:** An optional parameter, defaulting to the natural logarithm (`e`).
The base must be greater than 1.
- **Depth normalization:** `none`. This protocol does not rarefy or otherwise

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Be more explicit about what to do if a non-rarefied table is given (provide a warning not to compare across samples, and advise rarefaction)

(*Nature Communications*, 2025, DOI: 10.1038/s41467-025-66888-1) is an application
of the method, not the method-origin citation.

This protocol intentionally does not perform rarefaction. Because Shannon diversity

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Repetitive, consolidate rarefaction instructions above because it's more important than a note

the execution metadata, not as additional rows or columns in this output table.

## Notes

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we want notes about preferred software that implements this method in R and Python (e.g. in R, use the vegan package and function name)

@@ -0,0 +1,4 @@
feature_id,sample_a,sample_b

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is interesting because it's not normalized/rarefied. This should be expected to provide a warning to the user, in addition to the results.

@@ -0,0 +1,4 @@
feature_id,sample_a,sample_b

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This small table is appropriate for a test

evaluation:
mode: diagnostic
accepted_outcomes:
- outcome: refused_for_missing_values

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this part of the protocol standard? Probably what we needed is "error" or "refused"

mode: diagnostic
accepted_outcomes:
- outcome: refused_for_missing_values
expected_absent: [result]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not sure whether this is complementary to the outcome value - worth reviewing alongside the protocol standard. I would model tests against the testthat package, which allows for different types of assertions, including expect_warning, expect_error, expect_message, expect_value.

### Step 1: Validate the table and parameters

Read the input as a feature-by-sample table and preserve the sample column names.
Reject the input if the feature identifiers are missing or duplicated, if there are

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How to decide what belongs in Step 1 and what belongs in Materials? Are materials validated?

table. The calculation is descriptive: this protocol does not compare groups, test
hypotheses, or interpret the resulting values.

## Materials

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Come up with a strict definition of what belongs in materials, and how materials are validated.

- **Input scale:** A required parameter, either `counts` or `proportions`.
- **Logarithm base:** An optional parameter, defaulting to the natural logarithm (`e`).
The base must be greater than 1.
- **Depth normalization:** `none`. This protocol does not rarefy or otherwise

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Depth normalization is a description of the protocol, not a material.

@lwaldron

Copy link
Copy Markdown
Member

Hi @ohih8 , please see waldronlab/agent-protocol-standard#46 for instructions on clarifying how to specify the rarefaction recommendation in this PR.

This branch has not been deployed

No deployments
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.

Protocol: Shannon diversity of a single sample

2 participants