-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- removed unused code and associated tests - added tests of resample action - removed random_seed parameter (it seems to have not worked when I added tests, possibly b/c under the hood the randomization is happening with numpy.random, not Python's random) - this should be added back at some point, but i don't have time right now - see issue #18 - updated copyright headers - edited help text, refactored for re-use in related actions - added usage examples
- Loading branch information
1 parent
2c21ac7
commit 528682e
Showing
14 changed files
with
335 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# ---------------------------------------------------------------------------- | ||
# Copyright (c) 2024, Caporaso Lab (https://cap-lab.bio). | ||
# | ||
# Distributed under the terms of the Modified BSD License. | ||
# | ||
# The full license is in the file LICENSE, distributed with this software. | ||
# ---------------------------------------------------------------------------- | ||
|
||
import pandas as pd | ||
import qiime2 | ||
|
||
def table_factory(): | ||
table = pd.DataFrame(data=[[0, 1, 1], | ||
[10, 10, 9], | ||
[30, 20, 9], | ||
[42, 42, 9]], | ||
columns=['F1', 'F2', 'F3'], | ||
index=['S1', 'S2', 'S3', 'S4']) | ||
return qiime2.Artifact.import_data( | ||
"FeatureTable[Frequency]", table, view_type=pd.DataFrame) | ||
|
||
def _resample_bootstrap_example(use): | ||
table = use.init_artifact('table', table_factory) | ||
|
||
resampled_tables, = use.action( | ||
use.UsageAction(plugin_id='boots', | ||
action_id='resample'), | ||
use.UsageInputs(table=table, | ||
sampling_depth=20, | ||
n=10, | ||
replacement=True), | ||
use.UsageOutputNames(resampled_tables='bootstrapped_tables') | ||
) | ||
|
||
def _resample_rarefaction_example(use): | ||
table = use.init_artifact('table', table_factory) | ||
|
||
resampled_tables, = use.action( | ||
use.UsageAction(plugin_id='boots', | ||
action_id='resample'), | ||
use.UsageInputs(table=table, | ||
sampling_depth=20, | ||
n=10, | ||
replacement=False), | ||
use.UsageOutputNames(resampled_tables='rarefaction_tables') | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# ---------------------------------------------------------------------------- | ||
# Copyright (c) 2024, Caporaso Lab (https://cap-lab.bio). | ||
# | ||
# Distributed under the terms of the Modified BSD License. | ||
# | ||
# The full license is in the file LICENSE, distributed with this software. | ||
# ---------------------------------------------------------------------------- | ||
|
||
def resample(ctx, table, sampling_depth, n, replacement): | ||
rarefy_action = ctx.get_action('feature_table', 'rarefy') | ||
resampled_tables = [] | ||
|
||
for i in range(n): | ||
resampled_table = rarefy_action(table=table, | ||
sampling_depth=sampling_depth, | ||
with_replacement=replacement)[0] | ||
resampled_tables.append(resampled_table) | ||
|
||
return {f'resampled-table-{i}': t for i, t in enumerate(resampled_tables)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# ---------------------------------------------------------------------------- | ||
# Copyright (c) 2024, Caporaso Lab (https://cap-lab.bio). | ||
# | ||
# Distributed under the terms of the Modified BSD License. | ||
# | ||
# The full license is in the file LICENSE, distributed with this software. | ||
# ---------------------------------------------------------------------------- | ||
|
||
from qiime2.plugin.testing import TestPluginBase | ||
|
||
|
||
class UsageExampleTests(TestPluginBase): | ||
package = 'q2_boots.tests' | ||
|
||
def test_examples(self): | ||
self.execute_examples() |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.