Skip to content

Commit

Permalink
Convert submodules to namespace packages
Browse files Browse the repository at this point in the history
improves import performance and circular dependency issues
  • Loading branch information
theAeon committed Jan 31, 2024
1 parent e5551da commit 9b82aeb
Show file tree
Hide file tree
Showing 20 changed files with 50 additions and 64 deletions.
34 changes: 18 additions & 16 deletions src/pyliger/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
from .clustering import leiden_cluster, louvain_cluster
from .factorization import iNMF_HALS, online_iNMF, optimize_ALS
from .plotting import (
plot_by_dataset_and_cluster,
plot_gene,
plot_gene_loadings,
plot_spatial,
)
from .preprocessing import (
create_liger,
make_feature_matrix,
normalize,
scale_not_center,
select_genes,
)
from .clustering._leiden import leiden_cluster
from .clustering._louvain import louvain_cluster
from .factorization._iNMF_HALS import iNMF_HALS
from .factorization._online_iNMF import online_iNMF
from .factorization._iNMF_ANLS import optimize_ALS
from .plotting._dataset_cluster import plot_by_dataset_and_cluster
from .plotting._gene import plot_gene
from .plotting._gene_loadings import plot_gene_loadings
from .plotting._spatial import plot_spatial
from .preprocessing._initialization import create_liger
from .preprocessing._select_genes import select_genes
from .preprocessing._normalization import normalize
from .preprocessing._scale import scale_not_center
from .preprocessing._cal_feature import make_feature_matrix
from .read_write import read_10X, read_10X_h5, read_10X_visium
from .tools import quantile_norm, run_umap, run_wilcoxon
from .tools._quantile_norm import quantile_norm
from .tools._umap import run_umap
from .tools._wilcoxon import run_wilcoxon
from .pyliger import Liger
7 changes: 6 additions & 1 deletion src/pyliger/clustering/_leiden.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import leidenalg
import numpy as np

from ._utilities import _assign_cluster, build_igraph, compute_snn, run_knn
from pyliger.clustering._utilities import (
_assign_cluster,
build_igraph,
compute_snn,
run_knn,
)


def leiden_cluster(
Expand Down
7 changes: 6 additions & 1 deletion src/pyliger/clustering/_louvain.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import louvain
import numpy as np

from ._utilities import _assign_cluster, build_igraph, compute_snn, run_knn
from pyliger.clustering._utilities import (
_assign_cluster,
build_igraph,
compute_snn,
run_knn,
)


def louvain_cluster(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
from ._leiden import leiden_cluster
from ._louvain import louvain_cluster


#####TODO
def imputeKNN(
liger_object, reference, queries, knn_k=20, weight=True, norm=True, scale=False
Expand Down
2 changes: 1 addition & 1 deletion src/pyliger/factorization/_iNMF_ANLS.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
from tqdm import tqdm

from ._utilities import nnlsm_blockpivot
from pyliger.factorization._utilities import nnlsm_blockpivot


def optimize_ALS(
Expand Down
2 changes: 1 addition & 1 deletion src/pyliger/factorization/_iNMF_HALS.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import numpy as np

from ._utilities import (
from pyliger.factorization._utilities import (
_init_H,
_init_V,
_init_W,
Expand Down
10 changes: 5 additions & 5 deletions src/pyliger/factorization/_online_iNMF.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
from scipy.sparse import vstack
from tqdm import tqdm

from .._utilities import _h5_idx_generator
from ..preprocessing._initialization import _initialization_online
from ..preprocessing._normalization import _normalize_online
from ..preprocessing._scale import _scale_online
from ._utilities import (
from pyliger._utilities import _h5_idx_generator
from pyliger.preprocessing._initialization import _initialization_online
from pyliger.preprocessing._normalization import _normalize_online
from pyliger.preprocessing._scale import _scale_online
from pyliger.factorization._utilities import (
_init_V_online,
_init_W,
_update_V_HALS,
Expand Down
2 changes: 1 addition & 1 deletion src/pyliger/factorization/_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import scipy.linalg as sla
import scipy.sparse as sps

from .._utilities import _h5_idx_generator
from pyliger._utilities import _h5_idx_generator


def nonneg(x, eps=1e-16):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from ._iNMF_ANLS import optimize_ALS
from ._iNMF_HALS import iNMF_HALS
from ._online_iNMF import online_iNMF

#######################################################################################
#### Factorization TODO
Expand Down
2 changes: 1 addition & 1 deletion src/pyliger/plotting/_gene.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
)
from sklearn.preprocessing import scale

from ._utilities import get_gene_values
from pyliger.plotting._utilities import get_gene_values


def plot_gene(
Expand Down
3 changes: 2 additions & 1 deletion src/pyliger/plotting/_gene_loadings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
)
from tqdm import tqdm

from ..tools import calc_dataset_specificity, get_factor_markers
from pyliger.tools._marker import get_factor_markers
from pyliger.tools._metrics import calc_dataset_specificity


def plot_gene_loadings(
Expand Down
2 changes: 1 addition & 1 deletion src/pyliger/plotting/_spatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
ylim,
)

from ._utilities import get_gene_values
from pyliger.plotting._utilities import get_gene_values


def plot_spatial(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
# from ._qc import plot_qc
import numpy as np

from ._dataset_cluster import plot_by_dataset_and_cluster
from ._gene import plot_gene
from ._gene_loadings import plot_gene_loadings
from ._go import plot_go_term
from ._spatial import plot_spatial


###############TODO
Expand Down
6 changes: 0 additions & 6 deletions src/pyliger/preprocessing/__init__.py

This file was deleted.

4 changes: 2 additions & 2 deletions src/pyliger/preprocessing/_initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import numpy as np
from scipy.sparse import csr_matrix

from .._utilities import _h5_idx_generator, _merge_sparse_data_all, _remove_missing_obs
from ..pyliger import Liger
from pyliger._utilities import _h5_idx_generator, _merge_sparse_data_all, _remove_missing_obs
from pyliger.pyliger import Liger


def create_liger(
Expand Down
4 changes: 2 additions & 2 deletions src/pyliger/preprocessing/_normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import numpy as np
from sklearn.preprocessing import normalize as sp_normalize

from .._utilities import _h5_idx_generator, _remove_missing_obs
from ..pyliger import Liger
from pyliger._utilities import _h5_idx_generator, _remove_missing_obs
from pyliger.pyliger import Liger

PARRENT_PATH = Path(__file__).parent

Expand Down
2 changes: 1 addition & 1 deletion src/pyliger/preprocessing/_scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from scipy.sparse import csr_matrix
from sklearn.utils.sparsefuncs import inplace_column_scale

from .._utilities import _h5_idx_generator
from pyliger._utilities import _h5_idx_generator


def scale_not_center(
Expand Down
2 changes: 1 addition & 1 deletion src/pyliger/preprocessing/_select_genes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from scipy.stats import norm
from sklearn.utils.sparsefuncs import mean_variance_axis

from .._utilities import _h5_idx_generator
from pyliger._utilities import _h5_idx_generator


def select_genes(
Expand Down
4 changes: 2 additions & 2 deletions src/pyliger/tools/_marker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from scipy.sparse import vstack
from sklearn.preprocessing import scale

from ..tools import _wilcoxon, calc_dataset_specificity

from pyliger.tools import _wilcoxon
from pyliger.tools._metrics import calc_dataset_specificity

# Find shared and dataset-specific markers
def get_factor_markers(
Expand Down
7 changes: 0 additions & 7 deletions src/pyliger/tools/__init__.py → src/pyliger/tools/todo.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
from ._go import run_GO_analysis
from ._marker import get_factor_markers
from ._metrics import calc_dataset_specificity
from ._quantile_norm import quantile_norm
from ._umap import run_umap
from ._wilcoxon import _wilcoxon, run_wilcoxon

#######################################################################################
#### Conversion/Transformation TODO

Expand Down

0 comments on commit 9b82aeb

Please sign in to comment.