Skip to content

Multiple arsinh transforms? #262

@chillerb

Description

@chillerb

Is your feature request related to a problem? Please describe.
Hi Scott, I hope you are doing alright. While flowkit already provides an Asinh transform, it does seem to be somewhat different from the asinh transform that is offered in other popular packages like pytometry, cf. also here. Their arsinh transform only requires a single "co-factor" parameter - as far as I know, the transform was initially proposed by the flowVS paper:

Azad, A., Rajwa, B. & Pothen, A. flowVS: channel-specific variance stabilization in flow cytometry. BMC Bioinformatics 17, 291 (2016). https://doi.org/10.1186/s12859-016-1083-9

Describe the solution you'd like
Here, I propose a prototype implementation. For custom transforms, I think it would also be a good idea to expose the base transform class (I had to cheat a little bit).

"""
Extens flowkit by providing the popular flowVS arsinh transform with a co-factor parameter.
"""


import numpy as np
import flowkit as fk


class ArsinhTransform(fk.transforms._transforms.Transform):
    """
    Nonlinear transformation proposed by:

    > Azad, A., Rajwa, B. & Pothen, A. flowVS: channel-specific variance stabilization in flow cytometry. BMC Bioinformatics 17, 291 (2016). https://doi.org/10.1186/s12859-016-1083-9

    f(x) = arsinh(x / cofactor)

    :param param_cofactor: recommended value is 5 for CyTOF and 150 for Flow Cytometry
    """
    def __init__(self, param_cofactor=5):
        super().__init__()
        self.param_cofactor = param_cofactor


    def __repr__(self):
        return f"{self.__class__.__name__}(c: {self.param_cofactor})"

    def apply(self, events):
        """
        Apply transform to given events.

        :param events: NumPy array of FCS event data
        :return: NumPy array of transformed events
        """
        new_events = np.arcsinh(events / self.param_cofactor)

        return new_events

    def inverse(self, events):
        """
        Apply the inverse transform to given events.

        :param events: NumPy array of FCS event data
        :return: NumPy array of inversely transformed events
        """
        new_events = np.sinh(events) * self.param_cofactor

        return new_events

Additional context
I'm coming from a Computer Science PoV, so I don't know if what I'm proposing makes sense from a cytometry PoV.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions