Skip to content

Commit

Permalink
enviroment and installation
Browse files Browse the repository at this point in the history
  • Loading branch information
Rongtingting committed Jun 15, 2024
1 parent 70d31c2 commit 503363a
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 9 deletions.
12 changes: 9 additions & 3 deletions docs/FAQ.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ Top Questions
Input and Output
----------------

CNV Modules
CNA Modules
-----------

Parameters
----------

Version 0.3.4 specific issues
-----------------------------
Not support python >3.7.
Recommend XClone version 0.3.6 for Python >3.7 environment.

FileNotFoundError
~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -74,7 +76,9 @@ You may download the `anno_data` from the following URL and place the files unde
Version 0.3.5 specific issues
-----------------------------

Not reproted so far.
Not support python >3.7.
Recommend XClone version 0.3.6 for Python >3.7 environment.
No other issues reproted so far.


Dependency
Expand All @@ -89,6 +93,8 @@ You may encounter an error indicating that the `requests` module is not found (i
pip install requests
This Dependency issues solved in XClone version 0.3.6.

ModuleNotFoundError: No module named 'importlib.metadata'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -178,4 +184,4 @@ The most import step you may try is:
pip install scanpy
This Dependency issues solved in XClone version 0.3.6.
8 changes: 8 additions & 0 deletions docs/release.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Release History
===============

Version 0.3.6
-------------
- update Dependency for installation
- [Python version supporting] XClone support Python >3.7
adding a nonzero scalar to a sparse array is not supported by `scipy` in Python > 3.7 (which exists in RDR_smothing functions).



Version 0.3.5
-------------
- [BAF] add allele flip status for each gene in Local phasing and Global phasing
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
long_description = f.read()

reqs = ['numpy>=1.18', 'scipy', 'matplotlib', 'anndata',
'statsmodels', 'scanpy', 'h5py', 'palettable']
'statsmodels', 'scanpy', 'h5py', 'palettable', 'requests', 'importlib-metadata']

# seaborn

Expand Down
35 changes: 31 additions & 4 deletions xclone/model/_RDR_smoothing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# update: 2022/07/26

import numpy as np
import scanpy as sc
import scipy.sparse as sp
from .smoothing import WMA_smooth, KNN_smooth

## Smoothing strategy
Expand All @@ -25,12 +27,37 @@ def RDR_smoothing_base(Xdata,
"""
## preprocess
## normalization [follow scanpy pipeline]
# Xdata_norm.X = np.log(Xdata_norm.X/Xdata_norm.X.sum(1) * 10000 + 1)
# Notes: this only supported by python<3.7 if issparse
# sc.pp.normalize_total from the Scanpy library supports both dense and sparse matrices.

Xdata_norm = Xdata.copy()
Xdata_norm.X = np.log(Xdata_norm.X/Xdata_norm.X.sum(1) * 10000 + 1)

_is_ref = Xdata_norm.obs[cell_anno_key] == ref_celltype
Xdata_norm.var['ref_mean'] = Xdata_norm[_is_ref, :].X.mean(0)
Xdata_norm.var['ref_var'] = Xdata_norm[_is_ref, :].X.var(0)

# Normalize and log transform using scanpy functions
sc.pp.normalize_total(Xdata_norm, target_sum=10000)
sc.pp.log1p(Xdata_norm)

# Check if Xdata_norm.X is a sparse matrix
if sp.issparse(Xdata_norm.X):
# # Perform operations in a way that supports sparse matrices
# sums = np.array(Xdata_norm.X.sum(axis=1)).flatten()
# Xdata_norm.X = Xdata_norm.X.multiply(1 / sums[:, None])
# Xdata_norm.X = Xdata_norm.X.multiply(10000)
# # Create a sparse matrix of ones with the same shape
# ones_sparse = sp.csr_matrix(np.ones(Xdata_norm.X.shape))
# # Add the sparse matrix of ones to the original sparse matrix
# Xdata_norm.X = Xdata_norm.X + ones_sparse
# Xdata_norm.X.data = np.log(Xdata_norm.X.data)

Xdata_norm.var['ref_mean'] = np.array(Xdata_norm[_is_ref, :].X.mean(axis=0)).flatten()
ref_data_dense = Xdata_norm[_is_ref, :].X.toarray()
Xdata_norm.var['ref_var'] = ref_data_dense.var(axis=0)
else:
# Xdata_norm.X = np.log(Xdata_norm.X / Xdata_norm.X.sum(axis=1) * 10000 + 1)
Xdata_norm.var['ref_mean'] = Xdata_norm[_is_ref, :].X.mean(0)
Xdata_norm.var['ref_var'] = Xdata_norm[_is_ref, :].X.var(0)


adata_tmp = Xdata_norm.copy()
adata_tmp.X = adata_tmp.X - Xdata_norm.var['ref_mean'].values.reshape(1, -1)
Expand Down
2 changes: 1 addition & 1 deletion xclone/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.3.5"
__version__ = "0.3.6"

0 comments on commit 503363a

Please sign in to comment.