Package: mitoscripts
MitoScriptsThis Python package,MitoScripts, assists in quantifies mitochondrial morphology. It was written by me, Grant Hussey, as a rotation project in the Holt Lab at NYU Langone Health's Institute of Molecular Biomedicine.This package first requires data to be processed into 3D models by usingMitoGraph, an open-source software developed byMatheus Viana.This build of MitoScripts works for MitoGraph v3, and was tested on mammilian cells.General Notes and ProcedureMitoGraph is a software that takes z-stack images of mitochondria and produces a 3D model. This Python package,MitoScripts, takes the output from MitoGraph and quantifies it.Steps1. Acquire your data.Be sure to have a consistent naming scheme for these image files that do not repeat, in order to automate the quantification process downstream.2. Process your data through MitoGraph.3. Run MitoScripts.After MitoGraph processing is completed, you get.gnetand.mitographfiles. These are used by MitoScripts to quantify mitochondrial morphology.First, gather the.gnetand.mitographfiles into a single directory. Next, import the python package, which has three modules,mitographer,mitodata, andmitopca. You will most likely only interface withmitographer.As of now, MitoScripts works best if used in scientific mode in an IDE or a jupyter notebook.import mitodata as mtimport mitographer as mtgrapherimport mitopca as mtpca4. Run the analysis of choice.What MitoScripts Can DoMitoGrapher moduleThis is the most self-explainatory MitoScripts module. Interface with it to produce automated graphs based on your MitoGraph outputs,.gnetand.mitographfiles.create_graph_suitetakesdata_dir,data_name,name_dict, andsavefigs. Produces a scattered box plot graph for a plethora of quantifiable metrics from MitoGraph. This functionreturns a Pandas DataFramecontaining the extracted metrics.Keep this DataFrame for downstream analysis.data_dir: the directory of your.gnetand.mitographfiles.data_name: a user-defined name unique to the experiment (for example, "20oct19_treatment_with_chemical_x")name_dict: auser-defined dictionary that maps your filenames to their respective labels.savefigs: set this toTrueto save figures inside of your current directory.pca_suitetakesdf, or the DataFrame returned bycreate_graph_suite, and runs a PCA analysis. It also creates a scree plot and a centroid plot (where the centroid of each cluster is graphed instead of the points). It takesdf,to_drop, andstyle.df: as explained aboveto_drop: defaults to None. If None, will initialize to the automated output ofget_default_col_to_drop. This removes 1) redundant metrics and 2) irrevelant metrics. Set to a user-defined list if you want to customize the metrics used by MitoPCA.style: defaults to "tableau-colorblind10", a Seaborn style, as defined in the global variableDEFAULT_STYLE.scatter_length_distributiontakesdata_dir,data_name,name_dict, andsavefigs. Variable definitions are the same as above. This function will create a heatmap that displays the individual distributions of each image to visualize distribution of lengths in each image's greater mitochondrial network.MitoData moduleThis is the main backbone of the MitoGrapher module. Of note, there may be one function you'd interface with:analyze_imagestakesdata_dir,name_dict, anddata_nameand produces thedfexplained above.MitoPCA moduleThis module is the backbone ofmitographer.pca_suite. There is one notable function:run_special_pcauses an algorithm to drop columns producing the most dissimilarity in the data, then displays the resultant data's PCA graph. It takesdf,threshold,min_cols.thresholdandmin_colswork in tandem. They define two different conditions that the algorithm will stop.thresholddefines the max cutoff for PC 1's explained variance ratio, whilemin_colsdefines the min number of columns indfyou wish to keep in the final DataFrame.For example, let's say I have a DataFrame with 20 columns. The algorithm will start deleting columns that produce the most dissimiliarity. If deleting a column makes PC1's explanied variance ratio greater thanthreshold, it will stop deleting columns, then run a final PCA.Ifthresholdis not met, then the loop will continue.Simiarly, the algorithm checks each loop if you've whittled the DataFrame down belowmin_cols. If so, the algorithm will also stop deleting columns and run a final PCA.Other ThingsA longer description onname_dictname_dicthas key:value pairs as filename:treatment_name. For example, lets say you're treating cells with hydrogen peroxide and seeing if there is a change in mitochondrial morphology. You need to save your images in the form of "control_000", "control_001", "control_nnn" and "h2o2_000", "h2o2_001", "h2o2_nnn", then create a name_dict like so:name_dict = { 'control':'Control Group', 'h2o2':'With Hydrogen Peroxide' }This way, your graphs and variables will be displayed with the nicer headers "Control Group" and "With Hydrogen Peroxide."Extended notes for each stepFor Step 1:
Read the papers on MitoGraph (namelythis one) to follow best imaging practices for good MitoGraph results.For Step 2:
If you wish to use the normal MitoGraph pipeline, please seeMitoGraph's github repofor procedure. You may skip to the next step.Otherwise, if curious, I have provided here my own ImageJ macros based upon those supplied by Matheus that were useful in my pipeline. In order of use:Tiff_and_MaxProfs.ijm: This macro takes a directory of.nd2files, the output of our confocal microscope, and produces a.tifimage for each file. Next, it take sthe.tiffiles and produces a new z-stack containing max projections of each image.Use case:In the MitoGraph pipeline, you need to create such a z-stack to assist in cropping out individual cells from each image.CropCells_Complete.ijm: This macro takes a directory containing the.tiffiles from above, the max projection from above, and an ROISet.zip file containing ROIs for each cell (user-defined) and crops out the ROIs, creating one new.tifimage per ROI.Use case:In my pipeline, I need not only a directory containing each one file per cell ROI, as is used in the normal MitoGraph pipeline, but also a directory of directories where each directory contains a single ROI. This extra "directory of directories" is used on the compute cluster offered at my institution.createMontage.ijm: This macro creates a montage directly comparing the.pngfile output from MitoGraph (which displays the mitochondrial segmentation) to the original.tiffor manual quality control.Use case:Post-MitoGraph processing, use this to see if any catastrophic segmentation errors occured.Dependencies: 'numpy', 'pandas', 'scikit-learn', 'igraph', 'matplotlib', 'seaborn'. Please import these into your environment.