Skip to content

Comments

Pca-umap-cfret-update#68

Merged
axiomcura merged 8 commits intoWayScience:mainfrom
axiomcura:pca-umap-cfret-update
Feb 10, 2026
Merged

Pca-umap-cfret-update#68
axiomcura merged 8 commits intoWayScience:mainfrom
axiomcura:pca-umap-cfret-update

Conversation

@axiomcura
Copy link
Member

This PR updates the UMAP and PCA plots to separate by treatment and cell state. It also updates the notebooks that perform dimensionality reduction as well as the plotting notebooks.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@axiomcura axiomcura marked this pull request as ready for review February 9, 2026 17:53
@axiomcura axiomcura requested a review from wli51 February 9, 2026 17:53
Copy link
Contributor

@wli51 wli51 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Very informative figures.

One thing that stood out to me is whether the modified apply_pca still works with analysis from early on. If not, you might want to adjust the function such that it is backwards compatible. Please see comments in utils/preprocess.py

@@ -1,6 +1,10 @@
#!/usr/bin/env python

# In[15]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run id 15 in line 3 is crazy

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😅

random_state=0,
**kwargs,
) -> pl.DataFrame:
) -> tuple[pl.DataFrame, pl.DataFrame]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the sake of backwards compatibility with all the previous analysis you already have. I think it is best to add a boolean switch for whether the explained variance dataframe should be returned. The boolean switch should default to False, making the function by default only returning the PC dataframe and identical to the old return signature. For newer analysis that require the explained variance the boolean switch will need to be explicitly set as True.

Something like this:

def apply_pca(
    ...,
    return_var_explained: bool=False,
) -> pl.DataFrame | tuple[pl.DataFrame, pl.DataFrame]:
    ...

    pc_df = pl.concat(
        [
            profiles.select(meta_features),  # metadata df
            pl.DataFrame(
                principal_components, schema=pca_colnames
            ),  # PCA components df
        ],
        how="horizontal",
    )

    if return_var_explained:
        return pc_df,  explained_variance_df
    else:
        return pc_df

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really cool!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to make the 2 healthy frames more distinct from the failing frames? This should make the gif even more clear.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also appears that the off-target features are a lot less differentiable between healthy/failing + treated/dmso. Maybe this is evidence that the on scores should be viewed as much more important?

@axiomcura
Copy link
Member Author

Thanks for your review! now merging

@axiomcura axiomcura merged commit d263ef2 into WayScience:main Feb 10, 2026
@axiomcura axiomcura deleted the pca-umap-cfret-update branch February 10, 2026 21:58
@axiomcura axiomcura restored the pca-umap-cfret-update branch February 10, 2026 21:58
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

Successfully merging this pull request may close these issues.

2 participants