1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
# ----------------------------------------------------------------------------
# Copyright (c) 2016-2020, QIIME 2 development team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE, distributed with this software.
# ----------------------------------------------------------------------------
import numpy as np
from biom import Table
from qiime2.sdk.usage import UsageAction, UsageInputs, UsageOutputNames
from qiime2 import Artifact
def ft1_factory():
return Artifact.import_data(
'FeatureTable[Frequency]',
Table(np.array([[0, 1, 3], [1, 1, 2]]),
['O1', 'O2'],
['S1', 'S2', 'S3']))
def ft2_factory():
return Artifact.import_data(
'FeatureTable[Frequency]',
Table(np.array([[0, 2, 6], [2, 2, 4]]),
['O1', 'O3'],
['S4', 'S5', 'S6']))
def ft3_factory():
return Artifact.import_data(
'FeatureTable[Frequency]',
Table(np.array([[0, 4, 9], [4, 4, 8]]),
['O1', 'O4'],
['S7', 'S8', 'S9']))
def feature_table_merge_example(use):
feature_table1 = use.init_data('feature_table1', ft1_factory)
feature_table2 = use.init_data('feature_table2', ft2_factory)
merged_table = use.init_data_collection('merged_table', list,
feature_table1, feature_table2)
use.action(
UsageAction(plugin_id='feature_table',
action_id='merge'),
UsageInputs(tables=merged_table),
UsageOutputNames(merged_table='merged_table'),
)
def feature_table_merge_three_tables_example(use):
feature_table1 = use.init_data('feature_table1', ft1_factory)
feature_table2 = use.init_data('feature_table2', ft2_factory)
feature_table3 = use.init_data('feature_table3', ft3_factory)
merged_table = use.init_data_collection('merged_table', list,
feature_table1,
feature_table2,
feature_table3)
use.action(
UsageAction(plugin_id='feature_table',
action_id='merge'),
UsageInputs(tables=merged_table, overlap_method='sum'),
UsageOutputNames(merged_table='merged_table'),
)
|