Skip to content
Draft
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
Binary file added .coverage
Binary file not shown.
Binary file added pycrosstalker/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 3 additions & 3 deletions pycrosstalker/plots/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def plot_pca_LR_comparative(lrobj_tblPCA, pca_table, dims=(1, 2), ret=False, ggi

# Mapping Table
if include_tf:
map_df = pd.DataFrame(pca_df.index, columns=["gene"])
map_df = pd.DataFrame({"gene": pca_df.index})
map_df["mapping"] = map_df["gene"].apply(lambda gene: "Receptor" if "|R" in gene else ("Ligand" if "|L" in gene else "Transcription Factor"))
color_groups = ["#f8756b", "#00b835", "#619cff"]
else:
Expand Down Expand Up @@ -334,9 +334,9 @@ def plot_bar_rankings(annData, table_name, ranking, type = None, filter_sign = N
pass

if filter_sign == 'pos':
rankings_table = rankings_table[rankings_table['ranking'] > 0]
rankings_table = rankings_table[rankings_table[ranking] > 0]
elif filter_sign == 'neg':
rankings_table = rankings_table[rankings_table['ranking'] < 0]
rankings_table = rankings_table[rankings_table[ranking] < 0]


if rankings_table.empty:
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file added test/__init__.py
Empty file.
Binary file added test/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file not shown.
Binary file added test/__pycache__/helpers.cpython-312.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
22 changes: 22 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""
Shared pytest fixtures for pyCrossTalkeR tests.
"""
import pytest
from anndata import AnnData
from pycrosstalker import tools as cttl
from test.helpers import SEL_COLUMNS, make_lr_df # noqa: F401 – re-exported for tests

__all__ = ["SEL_COLUMNS", "make_lr_df"]


@pytest.fixture(scope="session")
def analysed_adata():
"""Fully analysed AnnData built from synthetic data (runs once per session)."""
adata = AnnData()
adata.uns['pycrosstalker'] = {
'path': {
'CTR': make_lr_df(0),
'EXP': make_lr_df(1),
}
}
return cttl.analise_LR(adata, save=False)
32 changes: 32 additions & 0 deletions test/helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""
Shared test helpers for pyCrossTalkeR tests.
"""
import numpy as np
import pandas as pd

SEL_COLUMNS = ['source', 'target', 'gene_A', 'gene_B', 'type_gene_A', 'type_gene_B', 'MeanLR']


def make_lr_df(seed=0):
"""Create a minimal synthetic LR interaction DataFrame.

Uses 3 cell types and 3 LR pairs so that PCA(n_components=2) always has
enough samples (3 nodes) and features (Listener, Influencer, Mediator).
"""
np.random.seed(seed)
cell_types = ['CellA', 'CellB', 'CellC']
lr_pairs = [('GENE_L1', 'GENE_R1'), ('GENE_L2', 'GENE_R2'), ('GENE_L3', 'GENE_R3')]
rows = []
for src in cell_types:
for tgt in cell_types:
for gl, gr in lr_pairs:
rows.append({
'source': src,
'target': tgt,
'gene_A': gl,
'gene_B': gr,
'type_gene_A': 'Ligand',
'type_gene_B': 'Receptor',
'MeanLR': abs(float(np.random.normal(1.5, 0.5))) + 0.1,
})
return pd.DataFrame(rows)
Loading