Skip to content

Commit

Permalink
avoid depreication
Browse files Browse the repository at this point in the history
  • Loading branch information
katosh committed Apr 22, 2024
1 parent 3203a45 commit b99f4ca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/palantir/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def from_10x(data_dir, use_ensemble_id=True):


def from_10x_HDF5(filename, genome=None):
ad = sc.read_10x_h5(filename, genome, True)
ad = sc.read_10x_h5(filename, genome=genome, gex_only=True)

dataMatrix = pd.DataFrame(ad.X.todense(), columns=ad.var_names, index=ad.obs_names)

Expand Down
7 changes: 5 additions & 2 deletions src/palantir/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,18 @@ def run_pca(
n_comps = n_components
else:
l_n_comps = min(1000, ad.n_obs - 1, ad.n_vars - 1)
sc.pp.pca(ad, n_comps=l_n_comps, use_highly_variable=True, zero_center=False)
sc.pp.pca(ad, n_comps=l_n_comps, mask_var="highly_variable", zero_center=False)
try:
n_comps = np.where(np.cumsum(ad.uns["pca"]["variance_ratio"]) > 0.85)[0][0]
except IndexError:
n_comps = n_components

# Rerun with selection number of components
n_comps = min(n_comps, ad.n_obs - 1, ad.n_vars - 1)
sc.pp.pca(ad, n_comps=n_comps, use_highly_variable=use_hvg, zero_center=False)
kwargs = dict()
if use_hvg:
kwargs["mask_var"] = "highly_variable"
sc.pp.pca(ad, n_comps=n_comps, zero_center=False, **kwargs)

if isinstance(data, sc.AnnData):
data.obsm[pca_key] = ad.obsm["X_pca"]
Expand Down

0 comments on commit b99f4ca

Please sign in to comment.