Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #307 #312

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion docs/yaml_docs/pipeline_preprocess_yml.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ Whether applying scaling or not is still a matter of debate, as stated in the [L
Specify if you want to save the prot normalised assay additionally as a txt file.

- <span class="parameter">pca</span> `Boolean`, Default: False<br>
Specify if you want to run PCA on the normalised protein data. This might be useful, when you have more than 50 features in your protein assay.
Specify if you want to run PCA on the normalised protein data. This might be useful, when you have more than 50 features in your protein assay. Further, this dimensionality reduction can be used in the integration workflow.

- <span class="parameter">n_pcs</span> `Integer`, Default: 50<br>
Number of principal components to compute. Specify at least n_pcs <= number of features -1.
Expand Down
10 changes: 5 additions & 5 deletions panpipes/python_scripts/batch_correct_bbknn.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@
L.warning("Dimred '%s' could not be found in adata.obsm. Computing PCA with default parameters." % dimred)
dimred = "X_pca"
n_pcs = 50
if adata.var.shape[0] < n_pcs:
L.info("You have less features than number of PCs you intend to calculate")
n_pcs = adata.var.shape[0] - 1
L.info("Setting n PCS to %i" % int(n_pcs))
L.info("Scaling data")
if adata.var.shape[0] < n_pcs or adata.obs.shape[0] < n_pcs:
L.info("You have less features/samples than number of PCs you intend to calculate")
n_pcs = min(adata.var.shape[0], adata.obs.shape[0]) - 1
L.info("Setting n PCS to %i" % int(n_pcs))
L.info("Scaling data")
sc.pp.scale(adata)
L.info("Computing PCA")
sc.tl.pca(adata, n_comps=n_pcs,
Expand Down
8 changes: 4 additions & 4 deletions panpipes/python_scripts/batch_correct_harmony.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@
L.warning("Dimred '%s' could not be found in adata.obsm. Computing PCA with default parameters." % dimred)
dimred = "X_pca"
n_pcs = 50
if adata.var.shape[0] < n_pcs:
L.info("You have less features than number of PCs you intend to calculate")
n_pcs = adata.var.shape[0] - 1
L.info("Setting n PCS to %i" % int(n_pcs))
if adata.var.shape[0] < n_pcs or adata.obs.shape[0] < n_pcs:
L.info("You have less features/samples than number of PCs you intend to calculate")
n_pcs = min(adata.var.shape[0], adata.obs.shape[0]) - 1
L.info("Setting n PCS to %i" % int(n_pcs))
L.info("Scaling data")
sc.pp.scale(adata)
L.info("Computing PCA")
Expand Down
13 changes: 6 additions & 7 deletions panpipes/python_scripts/batch_correct_none.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,16 @@


if dimred not in adata.obsm:
L.warning("Dimred '%s' could not be found in adata.obsm. Computing PCA with default parameters." % dimred)
L.warning("Dimred '%s' could not be found in adata.obsm. Computing PCA with default parameters." % dimred)
n_pcs = 50
if adata.var.shape[0] < n_pcs:
L.info("You have less features than number of PCs you intend to calculate")
n_pcs = adata.var.shape[0] - 1
L.info("Setting n PCS to %i" % int(n_pcs))
if adata.var.shape[0] < n_pcs or adata.obs.shape[0] < n_pcs:
L.info("You have less features/samples than number of PCs you intend to calculate")
n_pcs = min(adata.var.shape[0], adata.obs.shape[0]) - 1
L.info("Setting n PCS to %i" % int(n_pcs))
L.info("Scaling data")
sc.pp.scale(adata)
L.info("Computing PCA")
sc.tl.pca(adata, n_comps=n_pcs,
svd_solver='arpack',
sc.tl.pca(adata, n_comps=n_pcs, svd_solver='arpack',
random_state=0)
pc_kwargs['use_rep'] = "X_pca"
pc_kwargs['n_pcs'] = n_pcs
Expand Down