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

Simplification of cell type calling #98

Closed
MeyerBender opened this issue Oct 3, 2024 · 1 comment
Closed

Simplification of cell type calling #98

MeyerBender opened this issue Oct 3, 2024 · 1 comment

Comments

@MeyerBender
Copy link
Collaborator

Cell type and subtype calling is currently a bit cumbersome and should be simplified. Current syntax:

# processing and recomputing quantification
ds_processed = ds.pp[channels].pp.threshold(quantiles).pp.apply(medfilt2d, kernel_size=3).pp.add_quantification().pp.transform_expression_matrix(method='arcsinh')

# predicting major cell types
ds_with_ct_predictions = ds_processed.la.predict_cell_types_argmax(ct_marker_dict, key='_intensity', overwrite_existing_labels=True)

# merging processed image with segmentation etc. 
# thresholding specific markers and adding the final labels

There are a couple of things that could be simplified here:

  • add a channel argument to pp.threshold. This way, we can still threshold selected channels, and simply threshold non-listed channels at 0. This removes the step of having one thresholded and one non-thresholded object.
  • a hierarchical, all-in-one approach to cell type and subtype classification. This could for example look like this:
# predicting major cell types
ct_marker_dict = {'B': 'PAX5', 'T': 'CD3', 'Myeloid': 'CD11b', 'Dendritic': 'CD11c', 'Granulo': 'CD15', 'Macro': 'CD68', 'Stroma PDPN': 'Podoplanin', 'Stroma CD31': 'CD31', 'Stroma CD34': 'CD34', 'Stroma CD90': 'CD90', 'NK': 'CD56'}
ds = ds.la.predict_cell_types_argmax(ct_marker_dict)

# binarization of markers
# current syntax: ds.pp[marker].pp.threshold(intensity=threshold).pp.add_quantification(func=sp.percentage_positive, key_added='_perc_pos_filtered').la.threshold_labels({marker: perc_pos}, layer_key='_perc_pos_filtered')
ds = ds.pp.binarize(markers, thresholds)

# calling of cell subtypes with a provided hierarchy
subtype_dict = {
    'B': {
        'subtypes': [
            {
                'name': 'B_prol',
                'markers': ['Ki67']
            }
        ]
    },
    'T': {
        'subtypes': [
            {
                'name': 'T_h',
                'markers': ['CD4']
            },
            {
                'name': 'T_tox',
                'markers': ['CD8'],
                'subtypes': [
                    {
                        'name': 'T_tox_naive',
                        'markers': ['CD45RA']
                    },
                    {
                        'name': 'T_tox_mem',
                        'markers': ['CD45RO']
                    }
                ]
            }
        ]
    }
}

ds = ds.la.predict_cell_subtypes(subtype_dict)
@MeyerBender
Copy link
Collaborator Author

Addressed in #99, published with v0.6.0

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