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

OptionError: 'Pattern matched multiple keys' for scv.get_df() #906

Closed
hyjforesight opened this issue Jul 24, 2022 · 4 comments
Closed

OptionError: 'Pattern matched multiple keys' for scv.get_df() #906

hyjforesight opened this issue Jul 24, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@hyjforesight
Copy link

hyjforesight commented Jul 24, 2022

Hello scVelo,
I met a OptionError: 'Pattern matched multiple keys' when running scv.get_df() of the tutorial 'RNA Velocity Basics'.
Please see the code below.
Could you please help me with this issue?
Thanks!
Best,
YJ

adata.uns['neighbors']['distances'] = adata.obsp['distances']
adata.uns['neighbors']['connectivities'] = adata.obsp['connectivities']
scv.tl.paga(adata, groups='clusters', vkey='velocity', use_time_prior="velocity_pseudotime")

df = scv.get_df(adata, keys='paga/transitions_confidence', precision=2).T    # no error until this step
OptionError                               Traceback (most recent call last)
Input In [58], in <cell line: 1>()
----> 1 df = scv.get_df(adata, keys='paga/transitions_confidence', precision=2).T
      2 df.style.background_gradient(cmap='Blues').format('{:.2g}')

File ~\.conda\envs\new38\lib\site-packages\scvelo\core\_anndata.py:196, in get_df(data, keys, layer, index, columns, sort_values, dropna, precision)
    164 """Get dataframe for a specified adata key.
    165 
    166 Return values for specified key
   (...)
    192     A dataframe.
    193 """
    195 if precision is not None:
--> 196     pd.set_option("precision", precision)
    198 if isinstance(data, AnnData):
    199     keys, keys_split = (
    200         keys.split("*") if isinstance(keys, str) and "*" in keys else (keys, None)
    201     )

File ~\.conda\envs\new38\lib\site-packages\pandas\_config\config.py:256, in CallableDynamicDoc.__call__(self, *args, **kwds)
    255 def __call__(self, *args, **kwds):
--> 256     return self.__func__(*args, **kwds)

File ~\.conda\envs\new38\lib\site-packages\pandas\_config\config.py:149, in _set_option(*args, **kwargs)
    146     raise TypeError(f'_set_option() got an unexpected keyword argument "{kwarg}"')
    148 for k, v in zip(args[::2], args[1::2]):
--> 149     key = _get_single_key(k, silent)
    151     o = _get_registered_option(key)
    152     if o and o.validator:

File ~\.conda\envs\new38\lib\site-packages\pandas\_config\config.py:116, in _get_single_key(pat, silent)
    114     raise OptionError(f"No such keys(s): {repr(pat)}")
    115 if len(keys) > 1:
--> 116     raise OptionError("Pattern matched multiple keys")
    117 key = keys[0]
    119 if not silent:

OptionError: 'Pattern matched multiple keys'
Error output
# paste the error output here, if applicable
scvelo==0.2.4  scanpy==1.9.1  anndata==0.7.5  loompy==3.0.6  numpy==1.21.5  scipy==1.8.0  matplotlib==3.5.1  sklearn==1.0.2  pandas==1.4.1 
@hyjforesight hyjforesight added the bug Something isn't working label Jul 24, 2022
@WeilerP
Copy link
Member

WeilerP commented Jul 24, 2022

@hyjforesight, seems like an issue is related to Pandas not scVelo. I'm pretty sure the issue is that you are using older arguments for Pandas options (in your case precision). Starting from Pandas==1.4 some of the arguments are replaced by longer forms (display.precision in your case). See here. Please let me know if this resolves the problem.

@WeilerP WeilerP closed this as completed Jul 24, 2022
@hyjforesight
Copy link
Author

hello @WeilerP
Thanks for the response.

Because the parameters for scVelo is

scv.get_df(
    data: anndata._core.anndata.AnnData,
    keys: Union[str, List[str], NoneType] = None,
    layer: Union[str, NoneType] = None,
    index: List = None,
    columns: List = None,
    sort_values: bool = None,
    dropna: Literal['all', 'any'] = 'all',
    precision: int = None,
)

I set the argument precision=2. Should I replace precision as display.precision? But I got the errors as below:

df = scv.get_df(data=adata, keys='paga/transitions_confidence', display.precision=2).T
SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
df = scv.get_df(data=adata, keys='paga/transitions_confidence', display.precision==2).T
SyntaxError: positional argument follows keyword argument

@WeilerP
Copy link
Member

WeilerP commented Jul 25, 2022

Ah sorry, I thought it was a keyword directly passed to Pandas. Should have actually checked the code first. I opened a PR but unit tests are failing ATM. Will have to investigate once I find the time.

@WeilerP
Copy link
Member

WeilerP commented Oct 2, 2022

Fixed in #907.

@WeilerP WeilerP closed this as completed Oct 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants