diff --git a/q2_qsip2/_wrangling.py b/q2_qsip2/_wrangling.py index 7d12f02..6b277b9 100644 --- a/q2_qsip2/_wrangling.py +++ b/q2_qsip2/_wrangling.py @@ -5,10 +5,8 @@ # # The full license is in the file LICENSE, distributed with this software. # ---------------------------------------------------------------------------- -import pandas as pd -from collections import namedtuple -from typing import NamedTuple, Optional +from typing import Optional import qiime2 @@ -166,7 +164,7 @@ def _handle_metadata( metadata_type='source', extracted=extracted ) - sample_metadata =_validate_metadata_columns( + sample_metadata = _validate_metadata_columns( sample_metadata, sample_column_mapping, metadata_type='sample', diff --git a/q2_qsip2/plugin_setup.py b/q2_qsip2/plugin_setup.py index c37ac75..5ce9ea9 100644 --- a/q2_qsip2/plugin_setup.py +++ b/q2_qsip2/plugin_setup.py @@ -8,7 +8,7 @@ import importlib -from qiime2.plugin import Bool, Citations, List, Metadata, Plugin, Str +from qiime2.plugin import Citations, List, Metadata, Plugin, Str from q2_types.feature_table import FeatureTable, Frequency from q2_qsip2 import __version__ diff --git a/q2_qsip2/tests/test_wrangling.py b/q2_qsip2/tests/test_wrangling.py index 10bdcd3..e590f59 100644 --- a/q2_qsip2/tests/test_wrangling.py +++ b/q2_qsip2/tests/test_wrangling.py @@ -41,7 +41,7 @@ def test_extract_source_metadata(self): 'source-level-data': ['x', 'y'], }) - self.assertTrue( exp.equals(extracted) ) + self.assertTrue(exp.equals(extracted)) def metadata_to_validate(self): df = pd.DataFrame({ @@ -58,6 +58,7 @@ def metadata_column_mapping(self): 'isotope': None, 'isotopolog': 'my-isotopolog-col', } + def test_validate_metadata_columns(self): metadata = self.metadata_to_validate() columns_mapping = self.metadata_column_mapping() diff --git a/q2_qsip2/types/_deferred_setup/_transformers.py b/q2_qsip2/types/_deferred_setup/_transformers.py index 80f2f8b..1532248 100644 --- a/q2_qsip2/types/_deferred_setup/_transformers.py +++ b/q2_qsip2/types/_deferred_setup/_transformers.py @@ -1,10 +1,15 @@ -import pandas as pd +# ---------------------------------------------------------------------------- +# Copyright (c) 2024, 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. +# ---------------------------------------------------------------------------- + from rpy2.robjects.methods import RS4 import pickle -import qiime2 - from q2_qsip2.plugin_setup import plugin from q2_qsip2.types import QSIP2DataFormat diff --git a/q2_qsip2/types/_formats.py b/q2_qsip2/types/_formats.py index 1545102..c4d3432 100644 --- a/q2_qsip2/types/_formats.py +++ b/q2_qsip2/types/_formats.py @@ -5,12 +5,11 @@ # # The full license is in the file LICENSE, distributed with this software. # ---------------------------------------------------------------------------- -import pandas as pd + import rpy2.robjects as ro import pickle -import qiime2 from qiime2.plugin import ValidationError import qiime2.plugin.model as model diff --git a/q2_qsip2/types/_types.py b/q2_qsip2/types/_types.py index 72b805c..458ba35 100644 --- a/q2_qsip2/types/_types.py +++ b/q2_qsip2/types/_types.py @@ -6,7 +6,7 @@ # The full license is in the file LICENSE, distributed with this software. # ---------------------------------------------------------------------------- -from qiime2.plugin import SemanticType, ValidationError +from qiime2.plugin import SemanticType QSIP2Data = SemanticType('QSIP2Data') diff --git a/q2_qsip2/types/tests/test_formats.py b/q2_qsip2/types/tests/test_formats.py index 95445e3..7138eac 100644 --- a/q2_qsip2/types/tests/test_formats.py +++ b/q2_qsip2/types/tests/test_formats.py @@ -8,7 +8,6 @@ import biom import pandas as pd -from pandas.testing import assert_frame_equal import rpy2.robjects as ro from rpy2.robjects.methods import RS4 diff --git a/q2_qsip2/types/tests/test_transformers.py b/q2_qsip2/types/tests/test_transformers.py index e7ed990..a05d362 100644 --- a/q2_qsip2/types/tests/test_transformers.py +++ b/q2_qsip2/types/tests/test_transformers.py @@ -5,15 +5,13 @@ # # The full license is in the file LICENSE, distributed with this software. # ---------------------------------------------------------------------------- -import pandas as pd -from pandas.testing import assert_frame_equal + import rpy2.robjects as ro from rpy2.robjects.methods import RS4 import importlib.resources import pickle -import qiime2 from qiime2.plugin.testing import TestPluginBase from q2_qsip2.types import QSIP2DataFormat diff --git a/q2_qsip2/visualizers/_helpers.py b/q2_qsip2/visualizers/_helpers.py index c20042f..53fb5ce 100644 --- a/q2_qsip2/visualizers/_helpers.py +++ b/q2_qsip2/visualizers/_helpers.py @@ -1,21 +1,20 @@ # ---------------------------------------------------------------------------- -# Copyright (c) 2024, QIIME2. +# Copyright (c) 2024, 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 rpy2.robjects as ro from rpy2.robjects.packages import importr import importlib.resources from pathlib import Path import shutil -import tempfile ggplot2 = importr('ggplot2') + def _ggplot2_object_to_visualization( ggplot2_obj: object, output_dir: Path, width: int, height: int ) -> None: diff --git a/q2_qsip2/visualizers/_visualizers.py b/q2_qsip2/visualizers/_visualizers.py index e4f7136..2a09a1b 100644 --- a/q2_qsip2/visualizers/_visualizers.py +++ b/q2_qsip2/visualizers/_visualizers.py @@ -18,6 +18,7 @@ qsip2 = importr('qSIP2') + def plot_weighted_average_densities( output_dir: str, qsip_data: RS4, group: Optional[str] = None ) -> None: diff --git a/q2_qsip2/visualizers/tests/test_visualizers.py b/q2_qsip2/visualizers/tests/test_visualizers.py index e4c7926..a8483d4 100644 --- a/q2_qsip2/visualizers/tests/test_visualizers.py +++ b/q2_qsip2/visualizers/tests/test_visualizers.py @@ -8,7 +8,6 @@ from qiime2.plugin.testing import TestPluginBase -from q2_qsip2.visualizers._visualizers import plot_weighted_average_density class VisualizerTests(TestPluginBase): package = 'q2_qsip2.visualizers.tests' diff --git a/q2_qsip2/workflow.py b/q2_qsip2/workflow.py index b50412a..f3d6a72 100644 --- a/q2_qsip2/workflow.py +++ b/q2_qsip2/workflow.py @@ -6,8 +6,6 @@ # The full license is in the file LICENSE, distributed with this software. # ---------------------------------------------------------------------------- import biom -import pandas as pd -import rpy2 import rpy2.robjects as ro from rpy2.robjects.packages import importr from rpy2.robjects.methods import RS4 @@ -20,7 +18,6 @@ from q2_qsip2._wrangling import ( _construct_column_mapping, _handle_metadata, - _extract_source_metadata ) qsip2 = importr('qSIP2') @@ -35,7 +32,6 @@ def standard_workflow( return table - def create_qsip_data( table: biom.Table, sample_metadata: qiime2.Metadata, @@ -119,9 +115,9 @@ def create_qsip_data( table_df, feature_id='ASV' ) R_qsip_obj = qsip2.qsip_data( - source_data = R_source_obj, - sample_data = R_sample_obj, - feature_data = R_feature_obj + source_data=R_source_obj, + sample_data=R_sample_obj, + feature_data=R_feature_obj ) return R_qsip_obj