Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
v0.0.13 (2026-03-02)

### Bug fixes

* Update dependency updates
* See issue #117
* All back-compatible

v0.0.12 (2024-10-01)

Expand Down
38 changes: 28 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ Martino, C. and Shenhav, L. et al. Context-aware dimensionality reduction deconv
}
```


## Citation for RPCA

```
Expand All @@ -108,7 +107,6 @@ Martino, C. et al. A Novel Sparse Compositional Technique Reveals Microbial Pert
}
```


## Citation for Phylogenetic RPCA

```
Expand Down Expand Up @@ -137,20 +135,40 @@ Martino, C. et al. A Novel Sparse Compositional Technique Reveals Microbial Pert
## Citation for TEMPTED

```
Shi, p. et al. Time-Informed Dimensionality Reduction for Longitudinal Microbiome Studies. bioRxiv, (2023)
Shi, p. et al. TEMPTED: time-informed dimensionality reduction for longitudinal microbiome studies. Genome Biology, (2024)
```

```
@ARTICLE{Shi2023,
@ARTICLE{Shi2024,
author = {Shi, Pixu and Martino, Cameron and Han, Rungang and Janssen,
Stefan and Buck, Gregory and Serrano, Myrna and Owzar, Kouros and
Knight, Rob and Shenhav, Liat and Zhang, Anru R},
title = {{Time-Informed} Dimensionality Reduction for Longitudinal
Microbiome Studies},
year = {2023},
doi = {10.1101/2023.07.26.550749},
URL = {https://www.biorxiv.org/content/10.1101/2023.07.26.550749v1},
journal = {bioRxiv},
title = {TEMPTED: time-informed dimensionality reduction for longitudinal microbiome studies},
year = {2024},
doi = {10.1186/s13059-024-03453-x},
URL = {https://link.springer.com/article/10.1186/s13059-024-03453-x},
journal = {Genome Biology},
}
```

## Citation for Joint-RPCA

```
Cordazzo Vargas, b. et al. Joint-RPCA: Domain-Aware Multi-Omics Integration for Systems Microbiology. Molecular Systems Biology, (2026)
```

```
@ARTICLE{CordazzoVargas2026,
author = {Cordazzo Vargas, Bianca and Martino, Cameron and Dilmore, Amanda Hazel and Metcalf,
Jessica and Burcham, Zachary and Lahti, Leo and Bektanov, Aituar and Borman, Tuomas and
Salomaa, Veikko and Niiranen, Teemu and Havulinna, Aki and Gregor, Rachel and Eyal, Stav
and Meijler, Michael and Mizrahi, Itzhak and Song, Se and Bartko, Andrew and Dorrestein, Pieter
and Morton, James and McDonald, Daniel and Knight, Rob and Shenhav, Liat},
title = {Joint-RPCA: Domain-Aware Multi-Omics Integration for Systems Microbiology},
year = {2026},
doi = {},
URL = {},
journal = {Molecular Systems Biology},
}
```

Expand Down
2 changes: 1 addition & 1 deletion gemelli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
# The full license is in the file COPYING.txt, distributed with this software.
# ----------------------------------------------------------------------------

__version__ = "0.0.12"
__version__ = "0.0.13"
2 changes: 1 addition & 1 deletion gemelli/factorization.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def _fit(self):
raise ValueError('Input data is should be type numpy.ndarray')
# ensure the data contains missing values.
# other methods would be better in the case of fully dense data
n_entries = np.product(tensor.shape)
n_entries = np.prod(tensor.shape)
if self.check_dense:
if (np.count_nonzero(tensor) == n_entries and
np.count_nonzero(~np.isnan(tensor)) == n_entries):
Expand Down
13 changes: 9 additions & 4 deletions gemelli/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@
from inspect import getfullargspec
from gemelli._defaults import DEFAULT_MTD
from skbio.stats.composition import clr
from skbio.diversity._util import _vectorize_counts_and_tree
try:
# scikit-bio newer versions
from skbio.diversity._util import (
vectorize_counts_and_tree as _vectorize_counts_and_tree,
)
except ImportError:
# scikit-bio older versions
from skbio.diversity._util import _vectorize_counts_and_tree
from bp import parse_newick, to_skbio_treenode
from scipy.sparse.linalg import svds
# import QIIME2 if in a Q2env otherwise set type to str
Expand All @@ -30,8 +37,6 @@
except ImportError:
# python does not check but technically this is the type
NewickFormat = str


VALID_TAXONOMY_COLUMN_NAMES = ('taxon', 'taxonomy')


Expand Down Expand Up @@ -364,7 +369,7 @@ def tensor_rclr(T, branch_lengths=None):
+ [1] + conditions_index[:-1])
# transpose to flatten
T = T.transpose(forward_T)
M = T.reshape(np.product(T.shape[:len(T.shape) - 1]),
M = T.reshape(np.prod(T.shape[:len(T.shape) - 1]),
T.shape[-1])
with np.errstate(divide='ignore', invalid='ignore'):
M_tensor_rclr = matrix_rclr(M, branch_lengths=branch_lengths)
Expand Down
15 changes: 11 additions & 4 deletions gemelli/q2/_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,20 @@
from urllib.parse import quote
from skbio import DistanceMatrix
from gemelli.utils import qc_rarefaction as _qc_rarefaction
import pkg_resources
import seaborn as sns
import itertools
import matplotlib.pyplot as plt

TEMPLATES = pkg_resources.resource_filename('gemelli', 'q2')

# fix old and new dependency chnages
try:
from importlib.resources import files
TEMPLATES = files("gemelli").joinpath("q2")
except ImportError:
try:
from importlib_resources import files
TEMPLATES = files("gemelli").joinpath("q2")
except ImportError:
import pkg_resources
TEMPLATES = pkg_resources.resource_filename("gemelli", "q2")

def qc_rarefy(output_dir: str,
table: biom.Table,
Expand Down
5 changes: 5 additions & 0 deletions gemelli/q2/tests/test_rpca_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ def create_pos_cntrl_test_table(feature_prefix='',
class Testqc(unittest.TestCase):

def setUp(self):
# The positive/negative control tables are built with Subsample(),
# which draws from the global numpy RNG. Seed it so the controls are
# deterministic and the significance checks below are reproducible on
# CI (otherwise a borderline random draw can flip the p-value).
np.random.seed(0)
btneg, btpos = create_pos_cntrl_test_table()
self.btneg = Artifact.import_data("FeatureTable[Frequency]",
btneg)
Expand Down
16 changes: 12 additions & 4 deletions gemelli/rpca.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,10 +931,18 @@ def transform(ordination: OrdinationResults,
' the features in the ordination.'
' Either set subset_tables to True or'
' match the tables to the ordination.')
ordination.samples = transform_helper(Udf,
Vdf,
s_eig,
rclr_table_df)
projected_samples = transform_helper(Udf,
Vdf,
s_eig,
rclr_table_df)
ordination.samples = projected_samples
# In skbio >= 0.7, sample_ids is stored as a separate attribute at
# construction and is not re-derived when .samples is reassigned, so it
# must be updated explicitly to match the projected samples. Older skbio
# versions derive the ids from the .samples index and have no such
# attribute, so this is skipped there (back-compatible).
if hasattr(ordination, 'sample_ids'):
ordination.sample_ids = list(projected_samples.index)
return ordination


Expand Down
5 changes: 3 additions & 2 deletions gemelli/tempted.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,8 +780,9 @@ def tempted_helper(individual_id_tables,
individual_loadings.iloc[:, s] = a_hat
feature_loadings.iloc[:, s] = b_hat
state_loadings.iloc[:, s] = phi_hat.flatten()
lambda_coeff[s] = lambda_coeff_
rsquared[s] = 1 - resid / (y.size * y.var())
lambda_coeff[s] = np.asarray(lambda_coeff_).squeeze().item()
rsquared_ = 1 - resid / (y.size * y.var())
rsquared[s] = np.asarray(rsquared_).squeeze()
# update data
for i, (individual_id, m) in enumerate(tables_update.items()):
temp = tipos[i]
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ def run(self):
'biom-format',
'h5py',
'iow',
'matplotlib',
'seaborn',
'tax2tree'],
classifiers=classifiers,
entry_points={'qiime2.plugins': q2cmds,
Expand Down
Loading