Comments (4)
Have you tried replacing the original PCs with the harmonized PCs?
adjusted_pcs = pd.DataFrame(ho.Z_corr)
adata.obsm['X_pca'] = adjusted_pcs
You might also be able to add a new entry in the obsm
slot:
adata.obsm['X_pca_harmonized'] = adjusted_pcs
I did not test these snippets, so I don't know if they will work or not.
from harmonypy.
Thanks for your quick response!
In both cases I get a length error:
adjusted_pcs = pd.DataFrame(ho.Z_corr)
adata.obsm['X_pca'] = adjusted_pcs
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-93-d54e748e808d> in <module>
1 adjusted_pcs = pd.DataFrame(ho.Z_corr)
----> 2 adata.obsm['X_pca'] = adjusted_pcs
~/anaconda3/lib/python3.7/site-packages/anndata/_core/aligned_mapping.py in __setitem__(self, key, value)
148
149 def __setitem__(self, key: str, value: V):
--> 150 value = self._validate_value(value, key)
151 self._data[key] = value
152
~/anaconda3/lib/python3.7/site-packages/anndata/_core/aligned_mapping.py in _validate_value(self, val, key)
206 hasattr(val, "index")
207 and isinstance(val.index, cabc.Collection)
--> 208 and not (val.index == self.dim_names).all()
209 ):
210 # Could probably also re-order index if itβs contained
~/anaconda3/lib/python3.7/site-packages/pandas/core/indexes/base.py in cmp_method(self, other)
103 if isinstance(other, (np.ndarray, Index, ABCSeries, ExtensionArray)):
104 if other.ndim > 0 and len(self) != len(other):
--> 105 raise ValueError("Lengths must match to compare")
106
107 if is_object_dtype(self) and isinstance(other, ABCCategorical):
ValueError: Lengths must match to compare
---------------------------------------------------------------------------
Same thing also happens if I try to use
adata.obsm['X_pca'] = adjusted_pcs.values
ValueError: Value passed for key 'X_pca' is of incorrect shape. Values of obsm must match dimensions (0,) of parent. Value had shape (50, 29552) while it should have had (29552,).
Thanks for your time.
from harmonypy.
I think a simple transpose fixed the issue:
adjusted_pcs = pd.DataFrame(ho.Z_corr).T
adata.obsm['X_pca']=adjusted_pcs.values
Thanks!
from harmonypy.
Thanks for sharing the results. Glad you got it working.
from harmonypy.
Related Issues (17)
- ValueError: operands could not be broadcast together with shapes HOT 9
- Feature request: plot convergence HOT 1
- ValueError: operands could not be broadcast together HOT 1
- How to get the result after running harmony? HOT 2
- feature request: HOT 2
- run harmonypy true_divide error HOT 3
- Running multiple instances of the same variable in vars_use. HOT 5
- Runharmony with R and run_harmony with Python produced different results HOT 1
- Harmony with two or more covariates HOT 3
- Build changes have broken Conda install HOT 1
- Unique key is not in pandas describe HOT 3
- Failed to set number of max iterations to more than 10 HOT 2
- Error when trying to run Harmony with multiple covariates HOT 3
- Question re variance explained from harmony-corrected components HOT 4
- Try filprofiler HOT 1
- How to cite this work? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from harmonypy.