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

Plotly - Some plots throw error when making a new dataframe column #878

Closed
adkinsrs opened this issue Aug 26, 2024 · 4 comments
Closed

Plotly - Some plots throw error when making a new dataframe column #878

adkinsrs opened this issue Aug 26, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@adkinsrs
Copy link
Member

Encountered error: Cannot set a DataFrame with multiple columns to the single column y_rounded

Follow-up to #873.

The "y_rounded" column was made to use in hover text situations where we want to show only two sigfigs of precision when hovering over a plot.

@adkinsrs adkinsrs added the bug Something isn't working label Aug 26, 2024
@adkinsrs adkinsrs self-assigned this Aug 26, 2024
@carlocolantuoni
Copy link

context where i saw it:

for dataset "HIV infection and anti-retroviral treatment (ART) in cerebral organoids containing microglia." in this projection link i am getting "Encountered error: Cannot set a DataFrame with multiple columns to the single column y_rounded":
https://nemoanalytics.org/p?p=p&algo=pca&c=fc5b3499&l=623b2c0a

@adkinsrs adkinsrs changed the title Plotly - Some scatter plots throw error when making a new dataframe column Plotly - Some plots throw error when making a new dataframe column Aug 26, 2024
@adkinsrs
Copy link
Member Author

adkinsrs commented Aug 27, 2024

Ok figured it out sort of.

The projection pattern weight "PC1" could reference either the weight itself (stored in AnnData.var) or the "PC1" column in AnnData.obs from that troublesome dataset (and PC2 would also). I believe something in AnnData may be checking both adata.var and adata.obs for value names, as I have seen this behavior with scanpy functions also. In this case, it is causing the "PC1" column to disappear from intermediate output, and a second "raw_value" (expression) column is added which throws the error upon manipulation as a single column.

If you click "PC3" weight in the example above, the plot is successfully generated.

So now I need to find where in the code this mix-up is happening and fix that.

@adkinsrs
Copy link
Member Author

https://anndata.readthedocs.io/en/latest/generated/anndata.AnnData.to_df.html#anndata.AnnData.to_df

When converting from AnnData to DataFrame, the adata.var_names (index) values were being used, and for projections, I set these equal to the weights. So I just needed to rename the chosen weight value before converting to dataframe rather than after

@carlocolantuoni
Copy link

good sleuthing!

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