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

Examples with many covariates #6

Open
olgabot opened this issue May 22, 2015 · 0 comments
Open

Examples with many covariates #6

olgabot opened this issue May 22, 2015 · 0 comments

Comments

@olgabot
Copy link
Collaborator

olgabot commented May 22, 2015

Even after reading the code, I'm still confused about how to run this program with multiple covariates.

I thought I could do:

design = patsy.dmatrix('~ RIN + Index', metadata_expanded, return_type='dataframe')
combat(study.expression.data, ['RIN', 'Index'], design, numerical_covariates=['RIN'])

But I get this error (I copied the contents of combat.py to the flotilla package)


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-96-49a3d6446dc7> in <module>()
----> 1 combat(study.expression.data, ['RIN'], design, numerical_covariates=['RIN'])

/home/obotvinnik/workspace-git/flotilla/flotilla/external/combat.py in combat(data, batch, model, numerical_covariates)
     67 
     68     if model is not None and isinstance(model, pd.DataFrame):
---> 69         model["batch"] = list(batch)
     70     else:
     71         model = pd.DataFrame({'batch': batch})

/home/obotvinnik/anaconda/lib/python2.7/site-packages/pandas/core/frame.pyc in __setitem__(self, key, value)
   2108         else:
   2109             # set column
-> 2110             self._set_item(key, value)
   2111 
   2112     def _setitem_slice(self, key, value):

/home/obotvinnik/anaconda/lib/python2.7/site-packages/pandas/core/frame.pyc in _set_item(self, key, value)
   2185 
   2186         self._ensure_valid_index(value)
-> 2187         value = self._sanitize_column(key, value)
   2188         NDFrame._set_item(self, key, value)
   2189 

/home/obotvinnik/anaconda/lib/python2.7/site-packages/pandas/core/frame.pyc in _sanitize_column(self, key, value)
   2258         elif (isinstance(value, Index) or is_sequence(value)):
   2259             from pandas.core.series import _sanitize_index
-> 2260             value = _sanitize_index(value, self.index, copy=False)
   2261             if not isinstance(value, (np.ndarray, Index)):
   2262                 if isinstance(value, list) and len(value) > 0:

/home/obotvinnik/anaconda/lib/python2.7/site-packages/pandas/core/series.pyc in _sanitize_index(data, index, copy)
   2543 
   2544     if len(data) != len(index):
-> 2545         raise ValueError('Length of values does not match length of '
   2546                          'index')
   2547 

ValueError: Length of values does not match length of index
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant