smftools 0.3.1__py3-none-any.whl → 0.3.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- smftools/_version.py +1 -1
- smftools/cli/chimeric_adata.py +1563 -0
- smftools/cli/helpers.py +18 -2
- smftools/cli/hmm_adata.py +18 -1
- smftools/cli/latent_adata.py +522 -67
- smftools/cli/load_adata.py +2 -2
- smftools/cli/preprocess_adata.py +32 -93
- smftools/cli/recipes.py +26 -0
- smftools/cli/spatial_adata.py +23 -109
- smftools/cli/variant_adata.py +423 -0
- smftools/cli_entry.py +41 -5
- smftools/config/conversion.yaml +0 -10
- smftools/config/deaminase.yaml +3 -0
- smftools/config/default.yaml +49 -13
- smftools/config/experiment_config.py +96 -3
- smftools/constants.py +4 -0
- smftools/hmm/call_hmm_peaks.py +1 -1
- smftools/informatics/binarize_converted_base_identities.py +2 -89
- smftools/informatics/converted_BAM_to_adata.py +53 -13
- smftools/informatics/h5ad_functions.py +83 -0
- smftools/informatics/modkit_extract_to_adata.py +4 -0
- smftools/plotting/__init__.py +26 -12
- smftools/plotting/autocorrelation_plotting.py +22 -4
- smftools/plotting/chimeric_plotting.py +1893 -0
- smftools/plotting/classifiers.py +28 -14
- smftools/plotting/general_plotting.py +58 -3362
- smftools/plotting/hmm_plotting.py +1586 -2
- smftools/plotting/latent_plotting.py +804 -0
- smftools/plotting/plotting_utils.py +243 -0
- smftools/plotting/position_stats.py +16 -8
- smftools/plotting/preprocess_plotting.py +281 -0
- smftools/plotting/qc_plotting.py +8 -3
- smftools/plotting/spatial_plotting.py +1134 -0
- smftools/plotting/variant_plotting.py +1231 -0
- smftools/preprocessing/__init__.py +3 -0
- smftools/preprocessing/append_base_context.py +1 -1
- smftools/preprocessing/append_mismatch_frequency_sites.py +35 -6
- smftools/preprocessing/append_sequence_mismatch_annotations.py +171 -0
- smftools/preprocessing/append_variant_call_layer.py +480 -0
- smftools/preprocessing/flag_duplicate_reads.py +4 -4
- smftools/preprocessing/invert_adata.py +1 -0
- smftools/readwrite.py +109 -85
- smftools/tools/__init__.py +6 -0
- smftools/tools/calculate_knn.py +121 -0
- smftools/tools/calculate_nmf.py +18 -7
- smftools/tools/calculate_pca.py +180 -0
- smftools/tools/calculate_umap.py +70 -154
- smftools/tools/position_stats.py +4 -4
- smftools/tools/rolling_nn_distance.py +640 -3
- smftools/tools/sequence_alignment.py +140 -0
- smftools/tools/tensor_factorization.py +52 -4
- {smftools-0.3.1.dist-info → smftools-0.3.2.dist-info}/METADATA +3 -1
- {smftools-0.3.1.dist-info → smftools-0.3.2.dist-info}/RECORD +56 -42
- {smftools-0.3.1.dist-info → smftools-0.3.2.dist-info}/WHEEL +0 -0
- {smftools-0.3.1.dist-info → smftools-0.3.2.dist-info}/entry_points.txt +0 -0
- {smftools-0.3.1.dist-info → smftools-0.3.2.dist-info}/licenses/LICENSE +0 -0
|
@@ -5,8 +5,11 @@ from typing import Optional
|
|
|
5
5
|
import numpy as np
|
|
6
6
|
import pandas as pd
|
|
7
7
|
|
|
8
|
+
from smftools.logging_utils import get_logger
|
|
8
9
|
from smftools.optional_imports import require
|
|
9
10
|
|
|
11
|
+
logger = get_logger(__name__)
|
|
12
|
+
|
|
10
13
|
|
|
11
14
|
def plot_spatial_autocorr_grid(
|
|
12
15
|
adata,
|
|
@@ -39,6 +42,12 @@ def plot_spatial_autocorr_grid(
|
|
|
39
42
|
import os
|
|
40
43
|
import warnings
|
|
41
44
|
|
|
45
|
+
logger.info(
|
|
46
|
+
"Plotting spatial autocorrelation grid to %s for site_types=%s.",
|
|
47
|
+
out_dir,
|
|
48
|
+
site_types,
|
|
49
|
+
)
|
|
50
|
+
|
|
42
51
|
plt = require("matplotlib.pyplot", extra="plotting", purpose="autocorrelation plots")
|
|
43
52
|
|
|
44
53
|
# Try importing analyzer (used only as fallback)
|
|
@@ -98,7 +107,7 @@ def plot_spatial_autocorr_grid(
|
|
|
98
107
|
if sample_col not in adata.obs:
|
|
99
108
|
raise KeyError(f"sample_col '{sample_col}' not present in adata.obs")
|
|
100
109
|
samples = adata.obs[sample_col]
|
|
101
|
-
if not pd.
|
|
110
|
+
if not isinstance(samples.dtype, pd.CategoricalDtype):
|
|
102
111
|
samples = samples.astype("category")
|
|
103
112
|
sample_levels = list(samples.cat.categories)
|
|
104
113
|
|
|
@@ -107,7 +116,7 @@ def plot_spatial_autocorr_grid(
|
|
|
107
116
|
raise KeyError(f"reference_col '{reference_col}' not present in adata.obs")
|
|
108
117
|
if references is None:
|
|
109
118
|
refs_series = adata.obs[reference_col]
|
|
110
|
-
if not pd.
|
|
119
|
+
if not isinstance(refs_series.dtype, pd.CategoricalDtype):
|
|
111
120
|
refs_series = refs_series.astype("category")
|
|
112
121
|
references = list(refs_series.cat.categories)
|
|
113
122
|
references = list(references)
|
|
@@ -510,10 +519,10 @@ def plot_spatial_autocorr_grid(
|
|
|
510
519
|
try:
|
|
511
520
|
combined_df.to_csv(combined_out, index=False)
|
|
512
521
|
except Exception as e:
|
|
513
|
-
import warnings
|
|
514
|
-
|
|
515
522
|
warnings.warn(f"Failed to write combined CSV {combined_out}: {e}")
|
|
523
|
+
logger.warning("Failed to write combined CSV %s: %s", combined_out, e)
|
|
516
524
|
|
|
525
|
+
logger.info("Saved %s autocorrelation grid pages to %s.", len(saved_pages), out_dir)
|
|
517
526
|
return saved_pages
|
|
518
527
|
|
|
519
528
|
|
|
@@ -522,6 +531,7 @@ def plot_rolling_metrics(df, out_png=None, title=None, figsize=(10, 3.5), dpi=16
|
|
|
522
531
|
Plot NRL and SNR vs window center from the dataframe returned by rolling_autocorr_metrics.
|
|
523
532
|
If out_png is None, returns the matplotlib Figure object; otherwise saves PNG and returns path.
|
|
524
533
|
"""
|
|
534
|
+
logger.info("Plotting rolling metrics%s.", f" -> {out_png}" if out_png else "")
|
|
525
535
|
plt = require("matplotlib.pyplot", extra="plotting", purpose="autocorrelation plots")
|
|
526
536
|
|
|
527
537
|
# sort by center
|
|
@@ -546,6 +556,7 @@ def plot_rolling_metrics(df, out_png=None, title=None, figsize=(10, 3.5), dpi=16
|
|
|
546
556
|
|
|
547
557
|
if out_png:
|
|
548
558
|
fig.savefig(out_png, bbox_inches="tight")
|
|
559
|
+
logger.info("Saved rolling metrics plot to %s.", out_png)
|
|
549
560
|
if not show:
|
|
550
561
|
matplotlib = require("matplotlib", extra="plotting", purpose="autocorrelation plots")
|
|
551
562
|
|
|
@@ -604,6 +615,12 @@ def plot_rolling_grid(
|
|
|
604
615
|
"""
|
|
605
616
|
import os
|
|
606
617
|
|
|
618
|
+
logger.info(
|
|
619
|
+
"Plotting rolling metric grids for site=%s to %s (metrics=%s).",
|
|
620
|
+
site,
|
|
621
|
+
out_dir,
|
|
622
|
+
metrics,
|
|
623
|
+
)
|
|
607
624
|
plt = require("matplotlib.pyplot", extra="plotting", purpose="autocorrelation plots")
|
|
608
625
|
|
|
609
626
|
if per_metric_ylim is None:
|
|
@@ -708,6 +725,7 @@ def plot_rolling_grid(
|
|
|
708
725
|
fig.savefig(out_png, bbox_inches="tight")
|
|
709
726
|
plt.close(fig)
|
|
710
727
|
saved_pages.append(out_png)
|
|
728
|
+
logger.info("Saved rolling grid page to %s.", out_png)
|
|
711
729
|
|
|
712
730
|
pages_by_metric[metric] = saved_pages
|
|
713
731
|
|