### Install FlowKit from Source (Bash) Source: https://github.com/whitews/flowkit/blob/master/README.md Clones the FlowKit repository from GitHub, navigates into the directory, upgrades pip, and installs the library from the local source code. ```bash git clone https://github.com/whitews/flowkit cd flowkit pip install --upgrade pip pip install . ``` -------------------------------- ### Install FlowKit from PyPI (Bash) Source: https://github.com/whitews/flowkit/blob/master/README.md Installs the latest stable version of the FlowKit library from the Python Package Index using the pip package manager. ```bash pip install flowkit ``` -------------------------------- ### Checking FlowKit Version (Python) Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Displays the installed version of the `flowkit` library. This helps users verify they are using a compatible version with the tutorial and its API. ```python fk.__version__ ``` -------------------------------- ### Importing Libraries and Setting up Bokeh (Python) Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Imports the required libraries `bokeh`, `IPython.display`, and `flowkit`. Configures `bokeh` to render plots directly within a Jupyter notebook environment. This setup is necessary for visualizing data later in the tutorial. ```python import bokeh from bokeh.plotting import show from IPython.display import Image import flowkit as fk bokeh.io.output_notebook() ``` -------------------------------- ### Export Gate Hierarchy as Image in FlowKit Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Exports the gate hierarchy from a GatingStrategy instance as an image file (e.g., PNG). This method requires the graphviz package to be installed. ```python g_strat.export_gate_hierarchy_image('gs.png') ``` -------------------------------- ### Import Libraries and Setup Plotting in Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/advanced/compare-mfi-of-gated-events.ipynb Imports necessary Python libraries including os for path manipulation, numpy for numerical operations, pandas for data handling, and flowkit for flow cytometry data analysis. Sets up matplotlib for inline plotting in environments like Jupyter notebooks. ```python import os import numpy as np import pandas as pd import flowkit as fk %matplotlib inline ``` -------------------------------- ### Accessing GatingResults Report DataFrame (Python) Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Access the `report` attribute of a `GatingResults` instance to get a Pandas DataFrame containing statistics for each gate, including counts, percentages, and gate hierarchy information. ```python gs_results.report ``` -------------------------------- ### Select and Get a Specific Sample in Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/advanced/compare-mfi-of-gated-events.ipynb Selects a specific sample ID from the list and retrieves the corresponding Sample object from the workspace. This object contains data and metadata for the chosen sample. ```python # choose a sample ID sample_id = '101_DEN084Y5_15_E03_009_clean.fcs' sample = workspace.get_sample(sample_id) ``` -------------------------------- ### Filtering Raw Events Manually with Membership Array (Python) Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Retrieve raw events from a sample and then filter them using the boolean gate membership array to get only the events inside the gate. ```python gated_raw_events = sample.get_events(source='raw') gated_raw_events = gated_raw_events[cd3_pos_gate_membership] ``` -------------------------------- ### Get Sample IDs by Group in Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/advanced/compare-mfi-of-gated-events.ipynb Retrieves a list of sample IDs from the workspace that belong to a specified sample group, in this case, the group named 'DEN'. ```python sample_ids = workspace.get_sample_ids('DEN') ``` -------------------------------- ### Get Compensated Gated Events for FlowJo MFI in Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/advanced/compare-mfi-of-gated-events.ipynb Retrieves the event data for the 'CD4+' and 'CD8+' gates, specifically using the 'comp' source to get compensated but untransformed event values, which is often used in FlowJo's MFI calculation. ```python # Use the 'source' kwarg to specify just the compensated events cd4_events_comp = workspace.get_gate_events(sample_id, cd4_gate_name, source='comp') cd8_events_comp = workspace.get_gate_events(sample_id, cd8_gate_name, source='comp') ``` -------------------------------- ### Get Gated Events for a Population in Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/advanced/compare-mfi-of-gated-events.ipynb Retrieves the event data (as a pandas DataFrame) for events that fall within a specified gate, in this case, the 'CD4+' gate for the selected sample. ```python cd4_gate_name = 'CD4+' cd4_events = workspace.get_gate_events(sample_id, cd4_gate_name) ``` -------------------------------- ### Displaying GatingStrategy Object (Python) Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Prints the string representation of the `GatingStrategy` object created from the GatingML file. This output provides a summary of the loaded strategy, including the number of gates, transforms, and compensation matrices it contains. ```python g_strat ``` -------------------------------- ### Parsing GatingML File to Create GatingStrategy (Python) Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Defines the path to a GatingML XML file containing a gating strategy. Uses the `flowkit.parse_gating_xml()` function to load and parse the XML file, creating a `GatingStrategy` object representing the defined gates, compensation, and transformations. ```python gml_path = '../../data/8_color_data_set/8_color_ICS.xml' g_strat = fk.parse_gating_xml(gml_path) ``` -------------------------------- ### Load FCS Sample in FlowKit Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Loads an FCS file into a FlowKit Sample instance. This is the first step before applying a gating strategy or performing other operations on the data. ```python sample = fk.Sample("../../data/8_color_data_set/fcs_files/101_DEN084Y5_15_E01_008_clean.fcs") ``` -------------------------------- ### Apply Gating Strategy to Sample in FlowKit Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Applies a GatingStrategy instance to a loaded Sample instance using the gate_sample method. This process evaluates all gates in the hierarchy and returns a GatingResults instance. ```python gs_results = g_strat.gate_sample(sample, verbose=True) ``` -------------------------------- ### Initialize FlowKit Workspace in Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/advanced/compare-mfi-of-gated-events.ipynb Initializes a FlowKit Workspace object by providing the path to the FlowJo workspace file and the directory containing the associated FCS sample files. This loads the gating and analysis information from the workspace. ```python workspace = fk.Workspace(wsp_path, fcs_samples=sample_path) ``` -------------------------------- ### Display Workspace Summary in Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/advanced/compare-mfi-of-gated-events.ipynb Prints a summary of the loaded FlowKit workspace, providing an overview of its contents, such as the number of samples and groups. ```python workspace.summary() ``` -------------------------------- ### Display add_gate Docstring in FlowKit Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Displays the documentation string (docstring) for the add_gate method of the GatingStrategy class. This provides details on how to add custom gates to a strategy. ```python help(fk.GatingStrategy.add_gate) ``` -------------------------------- ### Display Sample IDs in Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/advanced/compare-mfi-of-gated-events.ipynb Prints the list of sample IDs retrieved from the specified group. ```python sample_ids ``` -------------------------------- ### Print ASCII Gate Hierarchy in FlowKit Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Prints the ASCII text representation of the gate hierarchy previously retrieved using get_gate_hierarchy. ```python print(text) ``` -------------------------------- ### Define Data File Paths in Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/advanced/compare-mfi-of-gated-events.ipynb Defines the base directory containing FCS files and the path to the FlowJo workspace (.wsp) file. These paths are used to locate the necessary input data for FlowKit. ```python base_dir = "../../../data/8_color_data_set" sample_path = os.path.join(base_dir, "fcs_files") wsp_path = os.path.join(base_dir, "8_color_ICS.wsp") ``` -------------------------------- ### Print Gate Hierarchy in ASCII in Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/advanced/compare-mfi-of-gated-events.ipynb Prints the hierarchical structure of gates applied to the selected sample in a readable ASCII format. This helps visualize the gating strategy. ```python print(workspace.get_gate_hierarchy(sample_id, 'ascii')) ``` -------------------------------- ### Display Exported Image in FlowKit Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Displays an image file, typically used in interactive environments like Jupyter notebooks to visualize the gate hierarchy image exported by export_gate_hierarchy_image. ```python Image('gs.png') ``` -------------------------------- ### Displaying Gate Membership Boolean Array (Python) Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Show the contents of the boolean NumPy array returned by `get_gate_membership`, where `True` indicates an event is inside the gate. ```python cd3_pos_gate_membership ``` -------------------------------- ### Retrieve Gate Hierarchy as Dictionary in FlowKit Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Retrieves the gate hierarchy from a GatingStrategy instance as a Python dictionary. The output='dict' option is used, providing a structure suitable for programmatic access within Python. ```python gs_dict = g_strat.get_gate_hierarchy(output='dict') ``` -------------------------------- ### Retrieve Gate Hierarchy as JSON in FlowKit Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Retrieves the gate hierarchy from a GatingStrategy instance as a JSON string. The output='json' option is used, and additional keywords like 'indent' can be passed to json.dumps. ```python gs_json = g_strat.get_gate_hierarchy(output='json', indent=2) ``` -------------------------------- ### Process Gates for a Sample in Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/advanced/compare-mfi-of-gated-events.ipynb Analyzes the gates defined in the workspace for the specified sample ID. This step applies the gating strategy to the sample's event data. ```python workspace.analyze_samples(sample_id=sample_id) ``` -------------------------------- ### Display Dictionary Gate Hierarchy in FlowKit Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Displays the Python dictionary representation of the gate hierarchy. This is useful in interactive environments like Jupyter notebooks to inspect the dictionary structure. ```python gs_dict ``` -------------------------------- ### Retrieve Gate Hierarchy as ASCII in FlowKit Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Retrieves the gate hierarchy from a GatingStrategy instance as a human-readable ASCII text string. This is the default output format for the get_gate_hierarchy method. ```python text = g_strat.get_gate_hierarchy(output='ascii') ``` -------------------------------- ### Retrieving Absolute Gate Percent from GatingResults (Python) Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Use the `get_gate_absolute_percent` method on a `GatingResults` instance to retrieve the percentage of events in a gate relative to the total sample events. ```python gs_results.get_gate_absolute_percent('CD3-pos') ``` -------------------------------- ### Retrieving Relative Gate Percent from GatingResults (Python) Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Use the `get_gate_relative_percent` method on a `GatingResults` instance to retrieve the percentage of events in a gate relative to its parent gate. ```python gs_results.get_gate_relative_percent('CD3-pos') ``` -------------------------------- ### Plot MFI Comparison Bar Chart in Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/advanced/compare-mfi-of-gated-events.ipynb Generates a bar plot comparing the Mean Fluorescence Intensity values for each fluorescence channel between the CD4+ and CD8+ populations using the transposed DataFrame. ```python ax = mfi_comparison.plot.bar(figsize=(12, 6)) ax.set_title("Mean Fluorescence Intensity - CD4+ vs CD8+", color='black', fontsize=18) ax.legend(bbox_to_anchor=(1.0, 1.0), fontsize=12) ax.set_xticklabels(ax.get_xticklabels(), rotation=45) ax.plot() ``` -------------------------------- ### Access Compensation Matrices in FlowKit Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Accesses the 'comp_matrices' attribute of the GatingStrategy instance. This attribute returns a dictionary where keys are compensation matrix IDs and values are Matrix instances. ```python g_strat.comp_matrices ``` -------------------------------- ### Display FlowJo Style MFI Comparison DataFrame in Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/advanced/compare-mfi-of-gated-events.ipynb Prints the DataFrame comparing the FlowJo-style median fluorescence intensity values for CD4+ and CD8+ populations. ```python fj_mfi_comparison ``` -------------------------------- ### Display MFI Comparison DataFrame in Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/advanced/compare-mfi-of-gated-events.ipynb Prints the DataFrame comparing the Mean Fluorescence Intensity values for CD4+ and CD8+ populations. ```python mfi_comparison ``` -------------------------------- ### Access Transformations in FlowKit Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Accesses the 'transformations' attribute of the GatingStrategy instance. This attribute returns a dictionary where keys are transformation IDs and values are transformation instances. ```python g_strat.transformations ``` -------------------------------- ### Filtering Raw Events with Sample.get_events event_mask (Python) Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Use the `event_mask` parameter of the `Sample.get_events` method with the boolean gate membership array to efficiently retrieve only the raw events inside the specified gate. ```python gated_raw_events = sample.get_events(source='raw', event_mask=cd3_pos_gate_membership) ``` -------------------------------- ### Print JSON Gate Hierarchy in FlowKit Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Prints the JSON string representation of the gate hierarchy previously retrieved using get_gate_hierarchy with output='json'. ```python print(gs_json) ``` -------------------------------- ### Display CD4+ MFI in Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/advanced/compare-mfi-of-gated-events.ipynb Prints the calculated Mean Fluorescence Intensity values for the CD4+ population. ```python cd4_mfi ``` -------------------------------- ### Display Transposed FlowJo Style MFI Comparison DataFrame in Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/advanced/compare-mfi-of-gated-events.ipynb Prints the transposed DataFrame comparing the FlowJo-style median fluorescence intensity values. ```python fj_mfi_comparison ``` -------------------------------- ### Retrieving Gate Membership Boolean Array (Python) Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Use the `get_gate_membership` method on a `GatingResults` instance to obtain a boolean NumPy array indicating which sample events belong to the specified gate. ```python cd3_pos_gate_membership = gs_results.get_gate_membership('CD3-pos') ``` -------------------------------- ### Create MFI Comparison DataFrame in Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/advanced/compare-mfi-of-gated-events.ipynb Creates a pandas DataFrame to compare the calculated Mean Fluorescence Intensity values between the 'CD4+' and 'CD8+' populations. ```python mfi_comparison = pd.DataFrame([cd4_mfi, cd8_mfi], index=[cd4_gate_name, cd8_gate_name]) ``` -------------------------------- ### Displaying Shape of Events Filtered with event_mask (Python) Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Show the dimensions (number of events and parameters) of the NumPy array containing raw events filtered using the `event_mask` option in `Sample.get_events`. ```python gated_raw_events.shape ``` -------------------------------- ### Specifying psutil Dependency (Python) Source: https://github.com/whitews/flowkit/blob/master/requirements.txt Specifies the required version for the `psutil` package, requiring version 5.9 or higher. Notes indicate this is in preparation for future Python 3.13 support. ```Python psutil>=5.9 ``` -------------------------------- ### Specifying anytree Dependency (Python) Source: https://github.com/whitews/flowkit/blob/master/requirements.txt Specifies the required version for the `anytree` package, requiring version 2.12 or higher. Notes indicate compatibility with Python 3.7 through 3.12. ```Python anytree>=2.12 ``` -------------------------------- ### Display Transposed MFI Comparison DataFrame in Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/advanced/compare-mfi-of-gated-events.ipynb Prints the transposed DataFrame comparing the Mean Fluorescence Intensity values. ```python mfi_comparison ``` -------------------------------- ### Plot FlowJo Style MFI Comparison Bar Chart in Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/advanced/compare-mfi-of-gated-events.ipynb Generates a bar plot comparing the FlowJo-style median fluorescence intensity values for each fluorescence channel between the CD4+ and CD8+ populations using the transposed DataFrame. ```python ax = fj_mfi_comparison.plot.bar(figsize=(12, 6)) ax.set_title("FlowJo MFI - CD4+ vs CD8+", color='black', fontsize=18) ax.legend(bbox_to_anchor=(1.0, 1.0), fontsize=12) ax.set_xticklabels(ax.get_xticklabels(), rotation=45) ax.plot() ``` -------------------------------- ### Displaying Shape of Manually Filtered Events (Python) Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Show the dimensions (number of events and parameters) of the NumPy array containing raw events filtered manually using the gate membership array. ```python gated_raw_events.shape ``` -------------------------------- ### Specifying lxml Dependency (Python) Source: https://github.com/whitews/flowkit/blob/master/requirements.txt Specifies the required version for the `lxml` package, requiring version 5.1 or higher. Notes indicate this version supports Python 3.6 through 3.12 and drops Python 2 support. ```Python lxml>=5.1 ``` -------------------------------- ### Specifying networkx Dependency (Python) Source: https://github.com/whitews/flowkit/blob/master/requirements.txt Specifies the required version for the `networkx` package, requiring version 3.2 or higher. Notes indicate this version drops support for Python 3.8 and supports 3.9 through 3.12. ```Python networkx>=3.2 ``` -------------------------------- ### Create FlowJo Style MFI Comparison DataFrame in Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/advanced/compare-mfi-of-gated-events.ipynb Creates a pandas DataFrame to compare the calculated median fluorescence intensity values (FlowJo style) between the 'CD4+' and 'CD8+' populations. ```python fj_mfi_comparison = pd.DataFrame([cd4_fj_mfi, cd8_fj_mfi], index=[cd4_gate_name, cd8_gate_name]) ``` -------------------------------- ### Calculate CD8+ MFI in Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/advanced/compare-mfi-of-gated-events.ipynb Retrieves events for the 'CD8+' gate, filters them to include only fluorescence channels, and calculates the mean fluorescence intensity for each marker in this population. ```python cd8_gate_name = 'CD8+' cd8_events = workspace.get_gate_events(sample_id, cd8_gate_name) cd8_mfi = cd8_events[fluoro_labels].mean() ``` -------------------------------- ### Retrieve Root Gates in FlowKit Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Retrieves a list of Gate instances located at the root level of the gating hierarchy. These are gates that do not have a parent gate defined within the strategy. ```python # Get the list of gates at the root level g_strat.get_root_gates() ``` -------------------------------- ### Extract Fluorescence Channel Labels in Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/advanced/compare-mfi-of-gated-events.ipynb Iterates through the indices of fluorescence channels in the sample and collects their corresponding parameter names (labels). These labels are used to select fluorescence columns from the event data. ```python fluoro_labels = [] for chan_idx in sample.fluoro_indices: fluoro_labels.append(sample.pnn_labels[chan_idx]) ``` -------------------------------- ### Display First Rows of Gated Events DataFrame in Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/advanced/compare-mfi-of-gated-events.ipynb Displays the first 5 rows of the pandas DataFrame containing the event data for the gated population ('CD4+'). ```python cd4_events.head(5) ``` -------------------------------- ### Retrieve Sample ID from Gating Results in FlowKit Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Accesses the 'sample_id' attribute of a GatingResults instance. This attribute provides the identifier for the sample that the gating strategy was applied to. ```python # get the Sample ID for the GatingResults instance gs_results.sample_id ``` -------------------------------- ### Specifying scipy Dependency (Python) Source: https://github.com/whitews/flowkit/blob/master/requirements.txt Specifies the required version for the `scipy` package, requiring version 1.11.1 or higher. Notes indicate version 1.11 dropped Python 3.8 support and 1.11.0 was yanked from PyPI. ```Python scipy>=1.11.1 ``` -------------------------------- ### Calculating Absolute Count from Membership Array (Python) Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Summing the boolean values in the gate membership NumPy array provides the total number of events (absolute count) within the gate. ```python cd3_pos_gate_membership.sum() ``` -------------------------------- ### Retrieve Gate Instance by Name in FlowKit Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Retrieves a specific Gate instance from the GatingStrategy by its name. This works directly if the gate name is unique within the hierarchy. ```python g_strat.get_gate('Singlets') ``` -------------------------------- ### Retrieve All Gate IDs in FlowKit Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Retrieves a list of all gate IDs defined within the GatingStrategy. A gate ID is represented as a tuple of (gate_name, gate_path). ```python g_strat.get_gate_ids() ``` -------------------------------- ### Calculate Median Fluorescence Intensity (FlowJo Style) in Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/advanced/compare-mfi-of-gated-events.ipynb Calculates the *median* value for each fluorescence channel within the compensated, untransformed gated events ('CD4+' and 'CD8+'). This replicates a common method used in FlowJo for MFI calculation. ```python # Calculate the median on those extracted gated populations cd4_fj_mfi = cd4_events_comp[fluoro_labels].median() cd8_fj_mfi = cd8_events_comp[fluoro_labels].median() ``` -------------------------------- ### Specifying flowio Dependency (Python) Source: https://github.com/whitews/flowkit/blob/master/requirements.txt Specifies the required version for the `flowio` package, requiring a version between 1.3.0 (inclusive) and 1.4 (exclusive). ```Python flowio>=1.3.0,<1.4 ``` -------------------------------- ### Transpose FlowJo Style MFI Comparison DataFrame in Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/advanced/compare-mfi-of-gated-events.ipynb Transposes the FlowJo-style MFI comparison DataFrame, swapping rows and columns, for plotting. ```python fj_mfi_comparison = fj_mfi_comparison.transpose() ``` -------------------------------- ### Compare Total vs Gated Event Count in Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/advanced/compare-mfi-of-gated-events.ipynb Compares the total number of events in the sample to the number of events found within the specified gate ('CD4+'). ```python sample.event_count, cd4_events.shape[0] ``` -------------------------------- ### Specifying flowutils Dependency (Python) Source: https://github.com/whitews/flowkit/blob/master/requirements.txt Specifies the required version for the `flowutils` package, requiring a version between 1.1.0 (inclusive) and 1.2 (exclusive). ```Python flowutils>=1.1.0,<1.2 ``` -------------------------------- ### Retrieving Absolute Gate Count from GatingResults (Python) Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Use the `get_gate_count` method on a `GatingResults` instance to retrieve the absolute event count for a specified gate by name or path. ```python gs_results.get_gate_count('CD3-pos') ``` -------------------------------- ### Transpose MFI Comparison DataFrame in Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/advanced/compare-mfi-of-gated-events.ipynb Transposes the MFI comparison DataFrame, swapping rows and columns, which is often useful for plotting. ```python mfi_comparison = mfi_comparison.transpose() ``` -------------------------------- ### Retrieve Child Gate IDs in FlowKit Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Retrieves a list of gate IDs for all child gates of a given gate name or gate ID. If the gate name is unambiguous, the path can be omitted. ```python g_strat.get_child_gate_ids('CD3-pos') ``` -------------------------------- ### Filter Gated Events for Fluorescence Channels in Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/advanced/compare-mfi-of-gated-events.ipynb Filters the DataFrame of gated events ('CD4+') to include only the columns corresponding to fluorescence channels, using the previously extracted labels. ```python cd4_events = cd4_events[fluoro_labels] ``` -------------------------------- ### Specifying contourpy Dependency (Python) Source: https://github.com/whitews/flowkit/blob/master/requirements.txt Specifies the required version for the `contourpy` package, requiring version 1.2.0 or higher. Notes indicate this version drops support for Python 3.8 and supports 3.9 through 3.12. ```Python contourpy>=1.2.0 ``` -------------------------------- ### Calculate Mean Fluorescence Intensity (MFI) in Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/advanced/compare-mfi-of-gated-events.ipynb Calculates the mean value for each fluorescence channel within the filtered 'CD4+' gated events DataFrame. This represents the Mean Fluorescence Intensity for each marker in this population. ```python cd4_mfi = cd4_events.mean() ``` -------------------------------- ### Specifying pandas Dependency (Python) Source: https://github.com/whitews/flowkit/blob/master/requirements.txt Specifies the required version for the `pandas` package, requiring version 2.1 or higher. Notes indicate this version drops support for Python 3.8. ```Python pandas>=2.1 ``` -------------------------------- ### Specifying bokeh Dependency (Python) Source: https://github.com/whitews/flowkit/blob/master/requirements.txt Specifies the required version for the `bokeh` package, requiring version 3.4 or higher. Notes indicate compatibility with Python 3.9 through 3.12. ```Python bokeh>=3.4 ``` -------------------------------- ### Specifying numpy Dependency (Python) Source: https://github.com/whitews/flowkit/blob/master/requirements.txt Specifies the required version for the `numpy` package, requiring a version between 1.22 (inclusive) and 2 (exclusive). Notes indicate this version is locked due to the numpy C API dependency in `flowutils`. ```Python numpy>=1.22,<2 ``` -------------------------------- ### Retrieve Parent Gate ID in FlowKit Python Source: https://github.com/whitews/flowkit/blob/master/docs/notebooks/flowkit-tutorial-part03-gating-strategy-and-gating-results-classes.ipynb Retrieves the gate ID of the parent gate for a given gate name or gate ID. If the gate name is unambiguous, the path can be omitted. ```python g_strat.get_parent_gate_id('CD3-pos') ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.