MorphoMapping - Example Usage#
This file demonstrates how to use the MorphoMapping package. It provides examples of important methods and aims to facilitate the use of our package.
Imports#
[77]:
from morphomapping import MM
Load object#
[78]:
mm_object1= MM()
Convert files#
[79]:
mm_object1.convert_to_CSV(fcs_path='./example/FCS_test_file.FCS', csv_path='./example/CSV_test_file.CSV')
File successfully converted to ./example/CSV_test_file.CSV.
[ ]:
mm_object1.read_CSV('./example/CSV_test_file.CSV',add_index=True, index_name='ID')
[81]:
mm_object1.get_df()
[81]:
| Area_M01 | Area_M02 | Area_M03 | Area_M04 | Area_M05 | Area_M06 | Area_M07 | Area_M08 | Area_M09 | Area_M10 | ... | Aspect_Ratio_Intensity_Inspire(M07__Ch07)_Ch07 | All | PMN | Singlets | Cytoplasts_and_PMN | Nucleated_cells_and_PMN | R1_and_Nucleated_cells_and_PMN | R2_and_PMN | PDL1minus_and_PMN | PDL1plus_and_PMN | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ID | |||||||||||||||||||||
| 0 | 91.333336 | 58.000000 | 54.444443 | 42.666668 | 39.222221 | 68.222221 | 48.333332 | 38.333332 | 79.333336 | 0.0 | ... | 0.627883 | 1.0 | 1.0 | 0.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 |
| 1 | 125.777779 | 64.444443 | 91.888885 | 44.111111 | 3.555556 | 80.555557 | 82.666664 | 50.111111 | 133.444443 | 0.0 | ... | 0.715426 | 1.0 | 1.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 |
| 2 | 93.666664 | 76.222221 | 60.555557 | 21.777779 | 10.777778 | 61.444443 | 34.444443 | 29.888889 | 85.888885 | 0.0 | ... | 0.988767 | 1.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 |
| 3 | 106.000000 | 88.555557 | 70.666664 | 17.000000 | 19.111111 | 72.444443 | 75.444443 | 44.000000 | 111.888885 | 0.0 | ... | 0.730149 | 1.0 | 1.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 |
| 4 | 127.777779 | 88.777779 | 105.666664 | 75.666664 | 52.777779 | 122.555557 | 111.000000 | 54.555557 | 139.777771 | 0.0 | ... | 0.769359 | 1.0 | 1.0 | 0.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 13914 | 122.555557 | 80.444443 | 98.000000 | 49.111111 | 15.444445 | 99.000000 | 71.444443 | 35.333332 | 131.888885 | 0.0 | ... | 0.973271 | 1.0 | 1.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 |
| 13915 | 118.000000 | 82.333336 | 63.888889 | 55.444443 | 41.888889 | 81.444443 | 94.888885 | 54.777779 | 127.111115 | 0.0 | ... | 0.763991 | 1.0 | 1.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 |
| 13916 | 125.000000 | 107.777779 | 123.555557 | 100.000000 | 0.000000 | 86.000000 | 60.888889 | 39.777779 | 109.888885 | 0.0 | ... | 0.743443 | 1.0 | 1.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 |
| 13917 | 114.222221 | 109.222221 | 112.777779 | 84.111115 | 1.000000 | 88.444443 | 62.555557 | 31.222221 | 112.444443 | 0.0 | ... | 0.828440 | 1.0 | 1.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 |
| 13918 | 116.777779 | 93.333336 | 65.666664 | 15.222222 | 26.333334 | 92.444443 | 76.444443 | 49.222221 | 106.222221 | 0.0 | ... | 0.920377 | 1.0 | 1.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 |
13919 rows × 340 columns
[82]:
mm_object1.get_features()
[82]:
['Area_M01',
'Area_M02',
'Area_M03',
'Area_M04',
'Area_M05',
'Area_M06',
'Area_M07',
'Area_M08',
'Area_M09',
'Area_M10',
'Area_M11',
'Area_M12',
'Area_MC',
'Aspect_Ratio_M01',
'Aspect_Ratio_M02',
'Aspect_Ratio_M03',
'Aspect_Ratio_M04',
'Aspect_Ratio_M05',
'Aspect_Ratio_M06',
'Aspect_Ratio_M07',
'Aspect_Ratio_M08',
'Aspect_Ratio_M09',
'Aspect_Ratio_M10',
'Aspect_Ratio_M11',
'Aspect_Ratio_M12',
'Aspect_Ratio_Intensity_M01_Ch01',
'Aspect_Ratio_Intensity_M02_Ch02',
'Aspect_Ratio_Intensity_M03_Ch03',
'Aspect_Ratio_Intensity_M04_Ch04',
'Aspect_Ratio_Intensity_M05_Ch05',
'Aspect_Ratio_Intensity_M06_Ch06',
'Aspect_Ratio_Intensity_M07_Ch07',
'Aspect_Ratio_Intensity_M08_Ch08',
'Aspect_Ratio_Intensity_M09_Ch09',
'Aspect_Ratio_Intensity_M10_Ch10',
'Aspect_Ratio_Intensity_M11_Ch11',
'Aspect_Ratio_Intensity_M12_Ch12',
'Bkgd_Mean_Ch01',
'Bkgd_Mean_Ch02',
'Bkgd_Mean_Ch03',
'Bkgd_Mean_Ch04',
'Bkgd_Mean_Ch05',
'Bkgd_Mean_Ch06',
'Bkgd_Mean_Ch07',
'Bkgd_Mean_Ch08',
'Bkgd_Mean_Ch09',
'Bkgd_Mean_Ch10',
'Bkgd_Mean_Ch11',
'Bkgd_Mean_Ch12',
'Modulation_M01_Ch01',
'Modulation_M02_Ch02',
'Modulation_M03_Ch03',
'Modulation_M04_Ch04',
'Modulation_M05_Ch05',
'Modulation_M06_Ch06',
'Modulation_M07_Ch07',
'Modulation_M08_Ch08',
'Modulation_M09_Ch09',
'Modulation_M10_Ch10',
'Modulation_M11_Ch11',
'Modulation_M12_Ch12',
'Contrast_M01_Ch01',
'Contrast_M02_Ch02',
'Contrast_M03_Ch03',
'Contrast_M04_Ch04',
'Contrast_M05_Ch05',
'Contrast_M06_Ch06',
'Contrast_M07_Ch07',
'Contrast_M08_Ch08',
'Contrast_M09_Ch09',
'Contrast_M10_Ch10',
'Contrast_M11_Ch11',
'Contrast_M12_Ch12',
'Gradient_RMS_M01_Ch01',
'Gradient_RMS_M02_Ch02',
'Gradient_RMS_M03_Ch03',
'Gradient_RMS_M04_Ch04',
'Gradient_RMS_M05_Ch05',
'Gradient_RMS_M06_Ch06',
'Gradient_RMS_M07_Ch07',
'Gradient_RMS_M08_Ch08',
'Gradient_RMS_M09_Ch09',
'Gradient_RMS_M10_Ch10',
'Gradient_RMS_M11_Ch11',
'Gradient_RMS_M12_Ch12',
'Intensity_MC_Ch01',
'Intensity_MC_Ch02',
'Intensity_MC_Ch03',
'Intensity_MC_Ch04',
'Intensity_MC_Ch05',
'Intensity_MC_Ch06',
'Intensity_MC_Ch07',
'Intensity_MC_Ch08',
'Intensity_MC_Ch09',
'Intensity_MC_Ch10',
'Intensity_MC_Ch11',
'Intensity_MC_Ch12',
'Mean_Pixel_M01_Ch01',
'Mean_Pixel_M02_Ch02',
'Mean_Pixel_M03_Ch03',
'Mean_Pixel_M04_Ch04',
'Mean_Pixel_M05_Ch05',
'Mean_Pixel_M06_Ch06',
'Mean_Pixel_M07_Ch07',
'Mean_Pixel_M08_Ch08',
'Mean_Pixel_M09_Ch09',
'Mean_Pixel_M10_Ch10',
'Mean_Pixel_M11_Ch11',
'Mean_Pixel_M12_Ch12',
'Median_Pixel_M01_Ch01',
'Median_Pixel_M02_Ch02',
'Median_Pixel_M03_Ch03',
'Median_Pixel_M04_Ch04',
'Median_Pixel_M05_Ch05',
'Median_Pixel_M06_Ch06',
'Median_Pixel_M07_Ch07',
'Median_Pixel_M08_Ch08',
'Median_Pixel_M09_Ch09',
'Median_Pixel_M10_Ch10',
'Median_Pixel_M11_Ch11',
'Median_Pixel_M12_Ch12',
'Max_Pixel_MC_Ch01',
'Max_Pixel_MC_Ch02',
'Max_Pixel_MC_Ch03',
'Max_Pixel_MC_Ch04',
'Max_Pixel_MC_Ch05',
'Max_Pixel_MC_Ch06',
'Max_Pixel_MC_Ch07',
'Max_Pixel_MC_Ch08',
'Max_Pixel_MC_Ch09',
'Max_Pixel_MC_Ch10',
'Max_Pixel_MC_Ch11',
'Max_Pixel_MC_Ch12',
'Raw_Max_Pixel_MC_Ch01',
'Raw_Max_Pixel_MC_Ch02',
'Raw_Max_Pixel_MC_Ch03',
'Raw_Max_Pixel_MC_Ch04',
'Raw_Max_Pixel_MC_Ch05',
'Raw_Max_Pixel_MC_Ch06',
'Raw_Max_Pixel_MC_Ch07',
'Raw_Max_Pixel_MC_Ch08',
'Raw_Max_Pixel_MC_Ch09',
'Raw_Max_Pixel_MC_Ch10',
'Raw_Max_Pixel_MC_Ch11',
'Raw_Max_Pixel_MC_Ch12',
'Raw_Min_Pixel_MC_Ch01',
'Raw_Min_Pixel_MC_Ch02',
'Raw_Min_Pixel_MC_Ch03',
'Raw_Min_Pixel_MC_Ch04',
'Raw_Min_Pixel_MC_Ch05',
'Raw_Min_Pixel_MC_Ch06',
'Raw_Min_Pixel_MC_Ch07',
'Raw_Min_Pixel_MC_Ch08',
'Raw_Min_Pixel_MC_Ch09',
'Raw_Min_Pixel_MC_Ch10',
'Raw_Min_Pixel_MC_Ch11',
'Raw_Min_Pixel_MC_Ch12',
'Length_M01',
'Length_M02',
'Length_M03',
'Length_M04',
'Length_M05',
'Length_M06',
'Length_M07',
'Length_M08',
'Length_M09',
'Length_M10',
'Length_M11',
'Length_M12',
'Width_M01',
'Width_M02',
'Width_M03',
'Width_M04',
'Width_M05',
'Width_M06',
'Width_M07',
'Width_M08',
'Width_M09',
'Width_M10',
'Width_M11',
'Width_M12',
'Height_M01',
'Height_M02',
'Height_M03',
'Height_M04',
'Height_M05',
'Height_M06',
'Height_M07',
'Height_M08',
'Height_M09',
'Height_M10',
'Height_M11',
'Height_M12',
'Saturation_Count_M01_Ch01',
'Saturation_Count_M02_Ch02',
'Saturation_Count_M03_Ch03',
'Saturation_Count_M04_Ch04',
'Saturation_Count_M05_Ch05',
'Saturation_Count_M06_Ch06',
'Saturation_Count_M07_Ch07',
'Saturation_Count_M08_Ch08',
'Saturation_Count_M09_Ch09',
'Saturation_Count_M10_Ch10',
'Saturation_Count_M11_Ch11',
'Saturation_Count_M12_Ch12',
'Saturation_Percent_M01_Ch01',
'Saturation_Percent_M02_Ch02',
'Saturation_Percent_M03_Ch03',
'Saturation_Percent_M04_Ch04',
'Saturation_Percent_M05_Ch05',
'Saturation_Percent_M06_Ch06',
'Saturation_Percent_M07_Ch07',
'Saturation_Percent_M08_Ch08',
'Saturation_Percent_M09_Ch09',
'Saturation_Percent_M10_Ch10',
'Saturation_Percent_M11_Ch11',
'Saturation_Percent_M12_Ch12',
'Bright_Detail_Intensity_R3_MC_Ch01',
'Bright_Detail_Intensity_R3_MC_Ch02',
'Bright_Detail_Intensity_R3_MC_Ch03',
'Bright_Detail_Intensity_R3_MC_Ch04',
'Bright_Detail_Intensity_R3_MC_Ch05',
'Bright_Detail_Intensity_R3_MC_Ch06',
'Bright_Detail_Intensity_R3_MC_Ch07',
'Bright_Detail_Intensity_R3_MC_Ch08',
'Bright_Detail_Intensity_R3_MC_Ch09',
'Bright_Detail_Intensity_R3_MC_Ch10',
'Bright_Detail_Intensity_R3_MC_Ch11',
'Bright_Detail_Intensity_R3_MC_Ch12',
'Time',
'Object_Number',
'Raw_Centroid_X',
'Raw_Centroid_Y',
'Flow_Speed',
'Intensity_Surface_Ch03',
'Intensity_Surface_Ch04',
'Intensity_Surface_Ch05',
'Intensity_Surface_Ch07',
'Intensity_Surface_Ch11',
'Circularity_Morphology(M07__Ch07)',
'Delta_Centroid_XY',
'Bright_Detail_Intensity_R7_M07_Ch07',
'Area_Morphology(M07__Ch07)',
'Bright_Detail_Similarity_R3_MC_Ch03_Ch04',
'Bright_Detail_Colocalization_3_MC_Ch03_Ch04_Ch06',
'Bright_Detail_Similarity_R3_MC_Ch03_Ch06',
'Bright_Detail_Similarity_R3_MC_Ch04_Ch06',
'CDD6_on_surface_(%)',
'Bright_Detail_Similarity_R3_MC_Ch03_Ch05',
'Bright_Detail_Similarity_R3_M01_Ch04_Ch05',
'Bright_Detail_Colocalization_3_MC_Ch03_Ch04_Ch05',
'Internalization_Intracellular_Ch03',
'Internalization_Intracellular_Ch04',
'Internalization_Intracellular_Ch02',
'Internalization_Intracellular_Ch05',
'Internalization_Intracellular_Ch07',
'Bright_Detail_Similarity_R3_MC_Ch04_Ch05',
'Circularity_M01',
'Diameter_M01',
'Perimeter_M01',
'Symmetry_3_M01_Ch07',
'Circularity_Morphology(M07__Ch07)_/_Intensity_Surface_Ch03',
'Bright_Detail_Similarity_R3_MC_Ch04_Ch11',
'Internalization_Intracellular_Ch11',
'Max_Pixel_Surface_Ch03',
'Max_Pixel_Surface_Ch04',
'Max_Pixel_Surface_Ch11',
'Max_Pixel_Intracellular_Ch04',
'Max_Pixel_Surface_Ch04_minus_Max_Pixel_Intracellular_Ch04',
'Max_Pixel_Surface_Ch04_/_Max_Pixel_Intracellular_Ch04',
'Intensity_Surface_Ch04_/_Intensity_MC_Ch04',
'Intensity_Surface_Ch11_/_Intensity_MC_Ch11',
'Intensity_MC_Ch11_minus_Bkgd_Mean_Ch11',
'Bright_Detail_Intensity_R3_Surface_Ch11',
'Max_Pixel_Surface_Ch03_/_Max_Pixel_MC_Ch03',
'Area_Threshold(M07__Ch07__40)',
'Circularity_Threshold(M07__Ch07__40)',
'Compactness_Threshold(M07__Ch07__40)_Ch07',
'Diameter_Threshold(M07__Ch07__40)',
'Elongatedness_Threshold(M07__Ch07__40)',
'Symmetry_2_Threshold(M07__Ch07__40)_Ch07',
'Symmetry_3_Threshold(M07__Ch07__40)_Ch07',
'Area_Morphology(M01__Ch01)',
'Ratio_cell/nucleus',
'Intensity_Cortical_Ch02',
'Intensity_nuclear_actin',
'Lobe_Count_Morphology(M07__Ch07)_Ch07',
'Major_Axis_MC',
'Cytoplasmic_size',
'Similarity_MC_Ch02_Ch07',
'Circularity_MC',
'Circularity_AdaptiveErode(M01__Ch01__95)',
'Delta_Centroid_XY_MC_Ch01_IntensityWeighted_MC_Ch01',
'Major_Axis_M02',
'Mean_Pixel_Morphology(M07__Ch07)_Ch07',
'Area_M01_/_Bright_Detail_Intensity_R7_M07_Ch07',
'Delta_Centroid_XY_MC_Ch07_IntensityWeighted_MC_Ch07',
'Contrast_Surface_Ch01',
'Spot_Distance_Min_Threshold(M07__Ch07__40)',
'Spot_Area_Min_Threshold(M07__Ch07__40)',
'Intensity_Cortical_F_actin',
'Intensity_Nuclear_f_actin',
'Cortical_F_actin_(%)',
'Nuclear_F_actin',
'Delta_Centroid_XY_MC_Ch01_M02_Ch02_IntensityWeighted',
'Area_Inspire(M07__Ch07)',
'Area_System(M07__Ch07__39)',
'Shape_Ratio_M01',
'Area_Component(1__Area__Peak(M07__Ch07__Bright__0)__Descending)',
'Area_Inspire(M01__Ch01)',
'cytoplasmic_size_Insp',
'Area_Inspire(M01__Ch01)_minus_Area_Inspire(M07__Ch07)',
'Area_Cytoplasm',
'Insp_cytoplasm_index',
'Circularity_Inspire(M07__Ch07)',
'Symmetry_2_Inspire(M01__Ch01)_Ch01',
'Symmetry_3_Inspire(M01__Ch01)_Ch01',
'Lobe_Count_Inspire(M01__Ch01)_Ch01',
'Spot_Count_Inspire(M01__Ch01)_8',
'Delta_Centroid_XY_Intesity_Weighted_Actin',
'H_Variance_Mean_Inspire(M01__Ch01)_Ch02_3',
'Compactness_Inspire(M01__Ch01)_Ch02',
'Ensquared_Energy_Ch02_4',
'H_Entropy_Mean_Inspire(M01__Ch01)_Ch02_3',
'Shape_Ratio_Inspire(M07__Ch07)',
'Aspect_Ratio_Inspire(M07__Ch07)',
'Aspect_Ratio_Intensity_Inspire(M07__Ch07)_Ch02',
'Aspect_Ratio_Inspire(M01__Ch01)',
'Aspect_Ratio_Intensity_Inspire(M01__Ch01)_Ch02',
'Shape_Ratio_Inspire(M02__Ch02)',
'Aspect_Ratio_Intensity_Inspire(M07__Ch07)_Ch07',
'All',
'PMN',
'Singlets',
'Cytoplasts_and_PMN',
'Nucleated_cells_and_PMN',
'R1_and_Nucleated_cells_and_PMN',
'R2_and_PMN',
'PDL1minus_and_PMN',
'PDL1plus_and_PMN']
Structure dataset#
Modify the data by adding new columns, selecting rows, and performing additional transformations.
[83]:
mm_object1.add_metadata('donor','ABC')
mm_object1.add_metadata('file_number',1)
mm_object1.select_condition('PDL1plus_and_PMN',1)
mm_object1.select_events(1500)
mm_object1.weighted_features(['Area_M01','Area_M02'],2)
[83]:
| Area_M01 | Area_M02 | Area_M03 | Area_M04 | Area_M05 | Area_M06 | Area_M07 | Area_M08 | Area_M09 | Area_M10 | ... | PMN | Singlets | Cytoplasts_and_PMN | Nucleated_cells_and_PMN | R1_and_Nucleated_cells_and_PMN | R2_and_PMN | PDL1minus_and_PMN | PDL1plus_and_PMN | donor | file_number | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ID | |||||||||||||||||||||
| 6 | 263.333344 | 204.000000 | 104.333336 | 82.666664 | 7.222222 | 82.222221 | 59.444443 | 38.888889 | 121.666664 | 0.000000 | ... | 1.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 | ABC | 1 |
| 7 | 305.333344 | 212.888885 | 152.333328 | 107.000000 | 0.000000 | 104.111115 | 78.333336 | 42.000000 | 151.666672 | 0.000000 | ... | 1.0 | 1.0 | 0.0 | 0.0 | 0.0 | 1.0 | 0.0 | 1.0 | ABC | 1 |
| 30 | 221.111115 | 165.111115 | 56.222221 | 44.666668 | 41.444443 | 83.222221 | 71.444443 | 51.111111 | 121.666664 | 0.000000 | ... | 1.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 | ABC | 1 |
| 36 | 275.777771 | 208.888885 | 109.555557 | 23.777779 | 15.555555 | 115.222221 | 48.777779 | 36.444443 | 140.000000 | 0.000000 | ... | 1.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 | ABC | 1 |
| 41 | 251.111115 | 148.222229 | 77.000000 | 63.111111 | 0.000000 | 116.222221 | 72.222221 | 44.666668 | 134.444443 | 0.000000 | ... | 1.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 | ABC | 1 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 13859 | 162.222229 | 101.333336 | 74.888885 | 50.666668 | 3.777778 | 71.222221 | 37.333332 | 34.777779 | 88.888885 | 0.000000 | ... | 1.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 | ABC | 1 |
| 13860 | 262.888885 | 192.666672 | 86.000000 | 47.444443 | 36.777779 | 76.666664 | 92.666664 | 53.222221 | 147.000000 | 0.000000 | ... | 1.0 | 0.0 | 1.0 | 0.0 | 0.0 | 1.0 | 0.0 | 1.0 | ABC | 1 |
| 13868 | 214.666672 | 152.000000 | 77.444443 | 60.777779 | 49.888889 | 98.888885 | 52.666668 | 63.111111 | 116.444443 | 22.666666 | ... | 1.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 | ABC | 1 |
| 13887 | 216.888885 | 159.555557 | 48.888889 | 24.444445 | 21.777779 | 85.777779 | 50.333332 | 43.444443 | 100.555557 | 0.000000 | ... | 1.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 | ABC | 1 |
| 13917 | 228.444443 | 218.444443 | 112.777779 | 84.111115 | 1.000000 | 88.444443 | 62.555557 | 31.222221 | 112.444443 | 0.000000 | ... | 1.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 | ABC | 1 |
1500 rows × 342 columns
Load second object#
[ ]:
mm_object2 = MM()
mm_object2.read_CSV('./example/CSV_test_file.CSV',add_index=True, index_name='ID')
mm_object2.add_metadata('donor','XYZ')
mm_object2.add_metadata('file_number',2)
mm_object2.select_condition('PDL1plus_and_PMN',1)
mm_object2.select_events(1500)
Read all CSV files in a given folder#
[ ]:
mm_object3 = MM()
mm_object3.read_files('./example',add_index=True,join='inner')
mm_object3.get_df()
Concatenate object 1 and object 2#
[86]:
df = mm_object2.get_df()
mm_object1.concat_df(df)
mm_object1.get_df()
[86]:
| Area_M01 | Area_M02 | Area_M03 | Area_M04 | Area_M05 | Area_M06 | Area_M07 | Area_M08 | Area_M09 | Area_M10 | ... | PMN | Singlets | Cytoplasts_and_PMN | Nucleated_cells_and_PMN | R1_and_Nucleated_cells_and_PMN | R2_and_PMN | PDL1minus_and_PMN | PDL1plus_and_PMN | donor | file_number | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 263.333344 | 204.000000 | 104.333336 | 82.666664 | 7.222222 | 82.222221 | 59.444443 | 38.888889 | 121.666664 | 0.000000 | ... | 1.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 | ABC | 1 |
| 1 | 305.333344 | 212.888885 | 152.333328 | 107.000000 | 0.000000 | 104.111115 | 78.333336 | 42.000000 | 151.666672 | 0.000000 | ... | 1.0 | 1.0 | 0.0 | 0.0 | 0.0 | 1.0 | 0.0 | 1.0 | ABC | 1 |
| 2 | 221.111115 | 165.111115 | 56.222221 | 44.666668 | 41.444443 | 83.222221 | 71.444443 | 51.111111 | 121.666664 | 0.000000 | ... | 1.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 | ABC | 1 |
| 3 | 275.777771 | 208.888885 | 109.555557 | 23.777779 | 15.555555 | 115.222221 | 48.777779 | 36.444443 | 140.000000 | 0.000000 | ... | 1.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 | ABC | 1 |
| 4 | 251.111115 | 148.222229 | 77.000000 | 63.111111 | 0.000000 | 116.222221 | 72.222221 | 44.666668 | 134.444443 | 0.000000 | ... | 1.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 | ABC | 1 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 2995 | 81.111115 | 50.666668 | 74.888885 | 50.666668 | 3.777778 | 71.222221 | 37.333332 | 34.777779 | 88.888885 | 0.000000 | ... | 1.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 | XYZ | 2 |
| 2996 | 131.444443 | 96.333336 | 86.000000 | 47.444443 | 36.777779 | 76.666664 | 92.666664 | 53.222221 | 147.000000 | 0.000000 | ... | 1.0 | 0.0 | 1.0 | 0.0 | 0.0 | 1.0 | 0.0 | 1.0 | XYZ | 2 |
| 2997 | 107.333336 | 76.000000 | 77.444443 | 60.777779 | 49.888889 | 98.888885 | 52.666668 | 63.111111 | 116.444443 | 22.666666 | ... | 1.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 | XYZ | 2 |
| 2998 | 108.444443 | 79.777779 | 48.888889 | 24.444445 | 21.777779 | 85.777779 | 50.333332 | 43.444443 | 100.555557 | 0.000000 | ... | 1.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 | XYZ | 2 |
| 2999 | 114.222221 | 109.222221 | 112.777779 | 84.111115 | 1.000000 | 88.444443 | 62.555557 | 31.222221 | 112.444443 | 0.000000 | ... | 1.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 | XYZ | 2 |
3000 rows × 342 columns
Structure dataset#
Remove unnecessary columns or features to simplify the dataset
[87]:
d_features=[
'Bkgd_Mean_Ch01',
'Bkgd_Mean_Ch02',
'Bkgd_Mean_Ch03',
'Bkgd_Mean_Ch04',
'Bkgd_Mean_Ch05',
'Bkgd_Mean_Ch06',
'Bkgd_Mean_Ch07',
'Bkgd_Mean_Ch08',
'Bkgd_Mean_Ch09',
'Bkgd_Mean_Ch10',
'Bkgd_Mean_Ch11',
'Bkgd_Mean_Ch12',
'Modulation_M01_Ch01',
'Modulation_M02_Ch02',
'Modulation_M03_Ch03',
'Modulation_M04_Ch04',
'Modulation_M05_Ch05',
'Modulation_M06_Ch06',
'Modulation_M07_Ch07',
'Modulation_M08_Ch08',
'Modulation_M09_Ch09',
'Modulation_M10_Ch10',
'Modulation_M11_Ch11',
'Modulation_M12_Ch12',
'Contrast_M01_Ch01',
'Contrast_M02_Ch02',
'Contrast_M03_Ch03',
'Contrast_M04_Ch04',
'Contrast_M05_Ch05',
'Contrast_M06_Ch06',
'Contrast_M07_Ch07',
'Contrast_M08_Ch08',
'Contrast_M09_Ch09',
'Contrast_M10_Ch10',
'Contrast_M11_Ch11',
'Contrast_M12_Ch12',
'Gradient_RMS_M01_Ch01',
'Gradient_RMS_M02_Ch02',
'Gradient_RMS_M03_Ch03',
'Gradient_RMS_M04_Ch04',
'Gradient_RMS_M05_Ch05',
'Gradient_RMS_M06_Ch06',
'Gradient_RMS_M07_Ch07',
'Gradient_RMS_M08_Ch08',
'Gradient_RMS_M09_Ch09',
'Gradient_RMS_M10_Ch10',
'Gradient_RMS_M11_Ch11',
'Gradient_RMS_M12_Ch12',
'Intensity_MC_Ch01',
'Intensity_MC_Ch02',
'Intensity_MC_Ch03',
'Intensity_MC_Ch04',
'Intensity_MC_Ch05',
'Intensity_MC_Ch06',
'Intensity_MC_Ch07',
'Intensity_MC_Ch08',
'Intensity_MC_Ch09',
'Intensity_MC_Ch10',
'Intensity_MC_Ch11',
'Intensity_MC_Ch12',
'Mean_Pixel_M01_Ch01',
'Mean_Pixel_M02_Ch02',
'Mean_Pixel_M03_Ch03',
'Mean_Pixel_M04_Ch04',
'Mean_Pixel_M05_Ch05',
'Mean_Pixel_M06_Ch06',
'Mean_Pixel_M07_Ch07',
'Mean_Pixel_M08_Ch08',
'Mean_Pixel_M09_Ch09',
'Mean_Pixel_M10_Ch10',
'Mean_Pixel_M11_Ch11',
'Mean_Pixel_M12_Ch12',
'Median_Pixel_M01_Ch01',
'Median_Pixel_M02_Ch02',
'Median_Pixel_M03_Ch03',
'Median_Pixel_M04_Ch04',
'Median_Pixel_M05_Ch05',
'Median_Pixel_M06_Ch06',
'Median_Pixel_M07_Ch07',
'Median_Pixel_M08_Ch08',
'Median_Pixel_M09_Ch09',
'Median_Pixel_M10_Ch10',
'Median_Pixel_M11_Ch11',
'Median_Pixel_M12_Ch12',
'Max_Pixel_MC_Ch01',
'Max_Pixel_MC_Ch02',
'Max_Pixel_MC_Ch03',
'Max_Pixel_MC_Ch04',
'Max_Pixel_MC_Ch05',
'Max_Pixel_MC_Ch06',
'Max_Pixel_MC_Ch07',
'Max_Pixel_MC_Ch08',
'Max_Pixel_MC_Ch09',
'Max_Pixel_MC_Ch10',
'Max_Pixel_MC_Ch11',
'Max_Pixel_MC_Ch12',
'Raw_Max_Pixel_MC_Ch01',
'Raw_Max_Pixel_MC_Ch02',
'Raw_Max_Pixel_MC_Ch03',
'Raw_Max_Pixel_MC_Ch04',
'Raw_Max_Pixel_MC_Ch05',
'Raw_Max_Pixel_MC_Ch06',
'Raw_Max_Pixel_MC_Ch07',
'Raw_Max_Pixel_MC_Ch08',
'Raw_Max_Pixel_MC_Ch09',
'Raw_Max_Pixel_MC_Ch10',
'Raw_Max_Pixel_MC_Ch11',
'Raw_Max_Pixel_MC_Ch12',
'Raw_Min_Pixel_MC_Ch01',
'Raw_Min_Pixel_MC_Ch02',
'Raw_Min_Pixel_MC_Ch03',
'Raw_Min_Pixel_MC_Ch04',
'Raw_Min_Pixel_MC_Ch05',
'Raw_Min_Pixel_MC_Ch06',
'Raw_Min_Pixel_MC_Ch07',
'Raw_Min_Pixel_MC_Ch08',
'Raw_Min_Pixel_MC_Ch09',
'Raw_Min_Pixel_MC_Ch10',
'Raw_Min_Pixel_MC_Ch11',
'Raw_Min_Pixel_MC_Ch12',
'Aspect_Ratio_Intensity_M01_Ch01',
'Aspect_Ratio_Intensity_M02_Ch02',
'Aspect_Ratio_Intensity_M03_Ch03',
'Aspect_Ratio_Intensity_M04_Ch04',
'Aspect_Ratio_Intensity_M05_Ch05',
'Aspect_Ratio_Intensity_M06_Ch06',
'Aspect_Ratio_Intensity_M07_Ch07',
'Aspect_Ratio_Intensity_M08_Ch08',
'Aspect_Ratio_Intensity_M09_Ch09',
'Aspect_Ratio_Intensity_M10_Ch10',
'Aspect_Ratio_Intensity_M11_Ch11',
'Aspect_Ratio_Intensity_M12_Ch12',
'Saturation_Count_M01_Ch01',
'Saturation_Count_M02_Ch02',
'Saturation_Count_M03_Ch03',
'Saturation_Count_M04_Ch04',
'Saturation_Count_M05_Ch05',
'Saturation_Count_M06_Ch06',
'Saturation_Count_M07_Ch07',
'Saturation_Count_M08_Ch08',
'Saturation_Count_M09_Ch09',
'Saturation_Count_M10_Ch10',
'Saturation_Count_M11_Ch11',
'Saturation_Count_M12_Ch12',
'Saturation_Percent_M01_Ch01',
'Saturation_Percent_M02_Ch02',
'Saturation_Percent_M03_Ch03',
'Saturation_Percent_M04_Ch04',
'Saturation_Percent_M05_Ch05',
'Saturation_Percent_M06_Ch06',
'Saturation_Percent_M07_Ch07',
'Saturation_Percent_M08_Ch08',
'Saturation_Percent_M09_Ch09',
'Saturation_Percent_M10_Ch10',
'Saturation_Percent_M11_Ch11',
'Saturation_Percent_M12_Ch12',
'Bright_Detail_Intensity_R3_MC_Ch01',
'Bright_Detail_Intensity_R3_MC_Ch02',
'Bright_Detail_Intensity_R3_MC_Ch03',
'Bright_Detail_Intensity_R3_MC_Ch04',
'Bright_Detail_Intensity_R3_MC_Ch05',
'Bright_Detail_Intensity_R3_MC_Ch06',
'Bright_Detail_Intensity_R3_MC_Ch07',
'Bright_Detail_Intensity_R3_MC_Ch08',
'Bright_Detail_Intensity_R3_MC_Ch09',
'Bright_Detail_Intensity_R3_MC_Ch10',
'Bright_Detail_Intensity_R3_MC_Ch11',
'Bright_Detail_Intensity_R3_MC_Ch12',
'Time',
'Object_Number',
'Raw_Centroid_X',
'Raw_Centroid_Y',
'Flow_Speed',
'Intensity_Surface_Ch03',
'Intensity_Surface_Ch04',
'Intensity_Surface_Ch05',
'Intensity_Surface_Ch07',
'Intensity_Surface_Ch11',
'Bright_Detail_Intensity_R7_M07_Ch07',
'Bright_Detail_Similarity_R3_MC_Ch03_Ch04',
'Bright_Detail_Colocalization_3_MC_Ch03_Ch04_Ch06',
'Bright_Detail_Similarity_R3_MC_Ch03_Ch06',
'Bright_Detail_Similarity_R3_MC_Ch04_Ch06',
'Max_Pixel_Surface_Ch03',
'Max_Pixel_Surface_Ch04',
'Max_Pixel_Surface_Ch11',
'Max_Pixel_Intracellular_Ch04',
'Max_Pixel_Surface_Ch04_minus_Max_Pixel_Intracellular_Ch04',
'Max_Pixel_Surface_Ch04_/_Max_Pixel_Intracellular_Ch04',
'Intensity_Surface_Ch04_/_Intensity_MC_Ch04',
'Intensity_Surface_Ch11_/_Intensity_MC_Ch11',
'Intensity_MC_Ch11_minus_Bkgd_Mean_Ch11',
'Bright_Detail_Intensity_R3_Surface_Ch11',
'Max_Pixel_Surface_Ch03_/_Max_Pixel_MC_Ch03',
'Intensity_Cortical_Ch02',
'Intensity_nuclear_actin',
'Delta_Centroid_XY_MC_Ch01_IntensityWeighted_MC_Ch01',
'Contrast_Surface_Ch01',
'Intensity_Cortical_F_actin',
'Intensity_Nuclear_f_actin',
'Delta_Centroid_XY_MC_Ch01_M02_Ch02_IntensityWeighted',
'Mean_Pixel_Morphology(M07__Ch07)_Ch07',
'Area_M01_/_Bright_Detail_Intensity_R7_M07_Ch07',
'Delta_Centroid_XY_MC_Ch07_IntensityWeighted_MC_Ch07',
'Spot_Distance_Min_Threshold(M07__Ch07__40)',
'Aspect_Ratio_Intensity_Inspire(M07__Ch07)_Ch02',
'Aspect_Ratio_Intensity_Inspire(M01__Ch01)_Ch02',
'Aspect_Ratio_Intensity_Inspire(M07__Ch07)_Ch07',
'Circularity_Morphology(M07__Ch07)_/_Intensity_Surface_Ch03',
'Delta_Centroid_XY_Intesity_Weighted_Actin',
'All',
'PMN',
'Singlets',
'Cytoplasts_and_PMN',
'Nucleated_cells_and_PMN',
'R1_and_Nucleated_cells_and_PMN',
'R2_and_PMN',
'PDL1minus_and_PMN',
'PDL1plus_and_PMN',
]
[88]:
mm_object1.drop_variables(*d_features)
mm_object1.get_features()
[88]:
['Area_M01',
'Area_M02',
'Area_M03',
'Area_M04',
'Area_M05',
'Area_M06',
'Area_M07',
'Area_M08',
'Area_M09',
'Area_M10',
'Area_M11',
'Area_M12',
'Area_MC',
'Aspect_Ratio_M01',
'Aspect_Ratio_M02',
'Aspect_Ratio_M03',
'Aspect_Ratio_M04',
'Aspect_Ratio_M05',
'Aspect_Ratio_M06',
'Aspect_Ratio_M07',
'Aspect_Ratio_M08',
'Aspect_Ratio_M09',
'Aspect_Ratio_M10',
'Aspect_Ratio_M11',
'Aspect_Ratio_M12',
'Length_M01',
'Length_M02',
'Length_M03',
'Length_M04',
'Length_M05',
'Length_M06',
'Length_M07',
'Length_M08',
'Length_M09',
'Length_M10',
'Length_M11',
'Length_M12',
'Width_M01',
'Width_M02',
'Width_M03',
'Width_M04',
'Width_M05',
'Width_M06',
'Width_M07',
'Width_M08',
'Width_M09',
'Width_M10',
'Width_M11',
'Width_M12',
'Height_M01',
'Height_M02',
'Height_M03',
'Height_M04',
'Height_M05',
'Height_M06',
'Height_M07',
'Height_M08',
'Height_M09',
'Height_M10',
'Height_M11',
'Height_M12',
'Circularity_Morphology(M07__Ch07)',
'Delta_Centroid_XY',
'Area_Morphology(M07__Ch07)',
'CDD6_on_surface_(%)',
'Bright_Detail_Similarity_R3_MC_Ch03_Ch05',
'Bright_Detail_Similarity_R3_M01_Ch04_Ch05',
'Bright_Detail_Colocalization_3_MC_Ch03_Ch04_Ch05',
'Internalization_Intracellular_Ch03',
'Internalization_Intracellular_Ch04',
'Internalization_Intracellular_Ch02',
'Internalization_Intracellular_Ch05',
'Internalization_Intracellular_Ch07',
'Bright_Detail_Similarity_R3_MC_Ch04_Ch05',
'Circularity_M01',
'Diameter_M01',
'Perimeter_M01',
'Symmetry_3_M01_Ch07',
'Bright_Detail_Similarity_R3_MC_Ch04_Ch11',
'Internalization_Intracellular_Ch11',
'Area_Threshold(M07__Ch07__40)',
'Circularity_Threshold(M07__Ch07__40)',
'Compactness_Threshold(M07__Ch07__40)_Ch07',
'Diameter_Threshold(M07__Ch07__40)',
'Elongatedness_Threshold(M07__Ch07__40)',
'Symmetry_2_Threshold(M07__Ch07__40)_Ch07',
'Symmetry_3_Threshold(M07__Ch07__40)_Ch07',
'Area_Morphology(M01__Ch01)',
'Ratio_cell/nucleus',
'Lobe_Count_Morphology(M07__Ch07)_Ch07',
'Major_Axis_MC',
'Cytoplasmic_size',
'Similarity_MC_Ch02_Ch07',
'Circularity_MC',
'Circularity_AdaptiveErode(M01__Ch01__95)',
'Major_Axis_M02',
'Spot_Area_Min_Threshold(M07__Ch07__40)',
'Cortical_F_actin_(%)',
'Nuclear_F_actin',
'Area_Inspire(M07__Ch07)',
'Area_System(M07__Ch07__39)',
'Shape_Ratio_M01',
'Area_Component(1__Area__Peak(M07__Ch07__Bright__0)__Descending)',
'Area_Inspire(M01__Ch01)',
'cytoplasmic_size_Insp',
'Area_Inspire(M01__Ch01)_minus_Area_Inspire(M07__Ch07)',
'Area_Cytoplasm',
'Insp_cytoplasm_index',
'Circularity_Inspire(M07__Ch07)',
'Symmetry_2_Inspire(M01__Ch01)_Ch01',
'Symmetry_3_Inspire(M01__Ch01)_Ch01',
'Lobe_Count_Inspire(M01__Ch01)_Ch01',
'Spot_Count_Inspire(M01__Ch01)_8',
'H_Variance_Mean_Inspire(M01__Ch01)_Ch02_3',
'Compactness_Inspire(M01__Ch01)_Ch02',
'Ensquared_Energy_Ch02_4',
'H_Entropy_Mean_Inspire(M01__Ch01)_Ch02_3',
'Shape_Ratio_Inspire(M07__Ch07)',
'Aspect_Ratio_Inspire(M07__Ch07)',
'Aspect_Ratio_Inspire(M01__Ch01)',
'Shape_Ratio_Inspire(M02__Ch02)',
'donor',
'file_number']
Rename columns using new labels
[89]:
label_mapping = {'Area_M01': 'Area F Actin', 'Area_M02': 'Area Nucleus'}
mm_object1.rename_variables(label_mapping)
mm_object1.get_features()
[89]:
['Area F Actin',
'Area Nucleus',
'Area_M03',
'Area_M04',
'Area_M05',
'Area_M06',
'Area_M07',
'Area_M08',
'Area_M09',
'Area_M10',
'Area_M11',
'Area_M12',
'Area_MC',
'Aspect_Ratio_M01',
'Aspect_Ratio_M02',
'Aspect_Ratio_M03',
'Aspect_Ratio_M04',
'Aspect_Ratio_M05',
'Aspect_Ratio_M06',
'Aspect_Ratio_M07',
'Aspect_Ratio_M08',
'Aspect_Ratio_M09',
'Aspect_Ratio_M10',
'Aspect_Ratio_M11',
'Aspect_Ratio_M12',
'Length_M01',
'Length_M02',
'Length_M03',
'Length_M04',
'Length_M05',
'Length_M06',
'Length_M07',
'Length_M08',
'Length_M09',
'Length_M10',
'Length_M11',
'Length_M12',
'Width_M01',
'Width_M02',
'Width_M03',
'Width_M04',
'Width_M05',
'Width_M06',
'Width_M07',
'Width_M08',
'Width_M09',
'Width_M10',
'Width_M11',
'Width_M12',
'Height_M01',
'Height_M02',
'Height_M03',
'Height_M04',
'Height_M05',
'Height_M06',
'Height_M07',
'Height_M08',
'Height_M09',
'Height_M10',
'Height_M11',
'Height_M12',
'Circularity_Morphology(M07__Ch07)',
'Delta_Centroid_XY',
'Area_Morphology(M07__Ch07)',
'CDD6_on_surface_(%)',
'Bright_Detail_Similarity_R3_MC_Ch03_Ch05',
'Bright_Detail_Similarity_R3_M01_Ch04_Ch05',
'Bright_Detail_Colocalization_3_MC_Ch03_Ch04_Ch05',
'Internalization_Intracellular_Ch03',
'Internalization_Intracellular_Ch04',
'Internalization_Intracellular_Ch02',
'Internalization_Intracellular_Ch05',
'Internalization_Intracellular_Ch07',
'Bright_Detail_Similarity_R3_MC_Ch04_Ch05',
'Circularity_M01',
'Diameter_M01',
'Perimeter_M01',
'Symmetry_3_M01_Ch07',
'Bright_Detail_Similarity_R3_MC_Ch04_Ch11',
'Internalization_Intracellular_Ch11',
'Area_Threshold(M07__Ch07__40)',
'Circularity_Threshold(M07__Ch07__40)',
'Compactness_Threshold(M07__Ch07__40)_Ch07',
'Diameter_Threshold(M07__Ch07__40)',
'Elongatedness_Threshold(M07__Ch07__40)',
'Symmetry_2_Threshold(M07__Ch07__40)_Ch07',
'Symmetry_3_Threshold(M07__Ch07__40)_Ch07',
'Area_Morphology(M01__Ch01)',
'Ratio_cell/nucleus',
'Lobe_Count_Morphology(M07__Ch07)_Ch07',
'Major_Axis_MC',
'Cytoplasmic_size',
'Similarity_MC_Ch02_Ch07',
'Circularity_MC',
'Circularity_AdaptiveErode(M01__Ch01__95)',
'Major_Axis_M02',
'Spot_Area_Min_Threshold(M07__Ch07__40)',
'Cortical_F_actin_(%)',
'Nuclear_F_actin',
'Area_Inspire(M07__Ch07)',
'Area_System(M07__Ch07__39)',
'Shape_Ratio_M01',
'Area_Component(1__Area__Peak(M07__Ch07__Bright__0)__Descending)',
'Area_Inspire(M01__Ch01)',
'cytoplasmic_size_Insp',
'Area_Inspire(M01__Ch01)_minus_Area_Inspire(M07__Ch07)',
'Area_Cytoplasm',
'Insp_cytoplasm_index',
'Circularity_Inspire(M07__Ch07)',
'Symmetry_2_Inspire(M01__Ch01)_Ch01',
'Symmetry_3_Inspire(M01__Ch01)_Ch01',
'Lobe_Count_Inspire(M01__Ch01)_Ch01',
'Spot_Count_Inspire(M01__Ch01)_8',
'H_Variance_Mean_Inspire(M01__Ch01)_Ch02_3',
'Compactness_Inspire(M01__Ch01)_Ch02',
'Ensquared_Energy_Ch02_4',
'H_Entropy_Mean_Inspire(M01__Ch01)_Ch02_3',
'Shape_Ratio_Inspire(M07__Ch07)',
'Aspect_Ratio_Inspire(M07__Ch07)',
'Aspect_Ratio_Inspire(M01__Ch01)',
'Shape_Ratio_Inspire(M02__Ch02)',
'donor',
'file_number']
Standardization/ Normalization#
Apply Min-Max normalization to a specific part of the dataset.
[90]:
mm_object1.minmax_norm('Area F Actin','Shape_Ratio_Inspire(M02__Ch02)')
mm_object1.get_df()
[90]:
| Area F Actin | Area Nucleus | Area_M03 | Area_M04 | Area_M05 | Area_M06 | Area_M07 | Area_M08 | Area_M09 | Area_M10 | ... | H_Variance_Mean_Inspire(M01__Ch01)_Ch02_3 | Compactness_Inspire(M01__Ch01)_Ch02 | Ensquared_Energy_Ch02_4 | H_Entropy_Mean_Inspire(M01__Ch01)_Ch02_3 | Shape_Ratio_Inspire(M07__Ch07) | Aspect_Ratio_Inspire(M07__Ch07) | Aspect_Ratio_Inspire(M01__Ch01) | Shape_Ratio_Inspire(M02__Ch02) | donor | file_number | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0.566978 | 0.502290 | 0.573610 | 0.644156 | 0.087131 | 0.447148 | 0.313243 | 0.377970 | 0.410785 | 0.00 | ... | 0.313591 | 0.761270 | 0.462252 | 0.780636 | 0.620690 | 0.686934 | 0.611811 | 0.722222 | ABC | 1 |
| 1 | 0.684735 | 0.526718 | 0.837508 | 0.833766 | 0.000000 | 0.596958 | 0.448057 | 0.408207 | 0.624901 | 0.00 | ... | 0.076305 | 0.535507 | 0.589105 | 0.433597 | 0.512821 | 0.555405 | 0.408304 | 0.325581 | ABC | 1 |
| 2 | 0.448598 | 0.395420 | 0.309102 | 0.348052 | 0.500000 | 0.453992 | 0.398890 | 0.496760 | 0.410785 | 0.00 | ... | 1.000000 | 0.767202 | 0.335122 | 0.910088 | 0.896552 | 0.957763 | 0.962465 | 0.896552 | ABC | 1 |
| 3 | 0.601869 | 0.515725 | 0.602321 | 0.185281 | 0.187668 | 0.673004 | 0.237113 | 0.354212 | 0.541634 | 0.00 | ... | 0.382121 | 0.757604 | 0.334155 | 0.841622 | 0.869565 | 0.961271 | 0.741346 | 0.266667 | ABC | 1 |
| 4 | 0.532710 | 0.349008 | 0.423335 | 0.491775 | 0.000000 | 0.679848 | 0.404441 | 0.434125 | 0.501983 | 0.00 | ... | 0.605582 | 0.605352 | 0.414423 | 0.948612 | 0.687500 | 0.741091 | 0.855884 | 0.000000 | ABC | 1 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 2995 | 0.056075 | 0.080916 | 0.411729 | 0.394805 | 0.045576 | 0.371863 | 0.155432 | 0.338013 | 0.176844 | 0.00 | ... | 0.678908 | 0.678608 | 0.390732 | 0.932213 | 0.857143 | 0.861827 | 0.920663 | 0.266667 | XYZ | 2 |
| 2996 | 0.197196 | 0.206412 | 0.472816 | 0.369697 | 0.443700 | 0.409125 | 0.550357 | 0.517279 | 0.591594 | 0.00 | ... | 0.391627 | 0.760775 | 0.463557 | 0.851694 | 0.045455 | 0.276153 | 0.186740 | 0.048780 | XYZ | 2 |
| 2997 | 0.129595 | 0.150534 | 0.425779 | 0.473593 | 0.601877 | 0.561217 | 0.264869 | 0.613391 | 0.373513 | 0.34 | ... | 0.121971 | 0.772110 | 0.509750 | 0.502878 | 0.846154 | 0.863870 | 0.783250 | 0.866667 | XYZ | 2 |
| 2998 | 0.132710 | 0.160916 | 0.268784 | 0.190476 | 0.262735 | 0.471483 | 0.248216 | 0.422246 | 0.260111 | 0.00 | ... | 0.431445 | 0.818263 | 0.344421 | 0.872232 | 0.833333 | 0.992552 | 0.829925 | 0.666667 | XYZ | 2 |
| 2999 | 0.148910 | 0.241832 | 0.620037 | 0.655411 | 0.012064 | 0.489734 | 0.335448 | 0.303456 | 0.344964 | 0.00 | ... | 0.454690 | 0.815170 | 0.466046 | 0.909651 | 0.814815 | 0.884373 | 0.758536 | 0.363636 | XYZ | 2 |
3000 rows × 123 columns
Apply Standard Scaler to a specific part of the dataset.
[91]:
mm_object1.stand_scaler('Area F Actin','Shape_Ratio_Inspire(M02__Ch02)')
mm_object1.get_df()
[91]:
| Area F Actin | Area Nucleus | Area_M03 | Area_M04 | Area_M05 | Area_M06 | Area_M07 | Area_M08 | Area_M09 | Area_M10 | ... | H_Variance_Mean_Inspire(M01__Ch01)_Ch02_3 | Compactness_Inspire(M01__Ch01)_Ch02 | Ensquared_Energy_Ch02_4 | H_Entropy_Mean_Inspire(M01__Ch01)_Ch02_3 | Shape_Ratio_Inspire(M07__Ch07) | Aspect_Ratio_Inspire(M07__Ch07) | Aspect_Ratio_Inspire(M01__Ch01) | Shape_Ratio_Inspire(M02__Ch02) | donor | file_number | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 1.337076 | 1.625742 | 0.897175 | 1.463912 | -0.628185 | -0.140131 | -0.261273 | -0.125493 | 0.123897 | -0.235168 | ... | -0.973292 | 0.012054 | 0.695038 | -0.205093 | -0.025373 | -0.702550 | -0.961786 | 0.549558 | ABC | 1 |
| 1 | 1.957742 | 1.799961 | 2.223853 | 2.425170 | -1.065478 | 0.965897 | 0.601929 | 0.120193 | 1.367473 | -0.235168 | ... | -2.296819 | -1.962752 | 2.418283 | -2.839864 | -0.371441 | -1.402301 | -2.109929 | -0.640646 | ABC | 1 |
| 2 | 0.713126 | 0.863530 | -0.432575 | -0.037230 | 1.443909 | -0.089601 | 0.287114 | 0.839701 | 0.123897 | -0.235168 | ... | 2.855345 | 0.063941 | -1.031957 | 0.777724 | 0.859653 | 0.738303 | 1.016538 | 1.072670 | ABC | 1 |
| 3 | 1.520976 | 1.721562 | 1.041512 | -0.862419 | -0.123617 | 1.527333 | -0.748728 | -0.318532 | 0.883860 | -0.235168 | ... | -0.591044 | -0.020016 | -1.045098 | 0.257919 | 0.773074 | 0.756964 | -0.230971 | -0.817432 | ABC | 1 |
| 4 | 1.156458 | 0.532512 | 0.141705 | 0.691394 | -1.065478 | 1.577862 | 0.322658 | 0.330781 | 0.653568 | -0.235168 | ... | 0.655372 | -1.351795 | 0.045301 | 1.070207 | 0.188969 | -0.414427 | 0.415230 | -1.617622 | ABC | 1 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 2995 | -1.355761 | -1.379551 | 0.083355 | 0.199792 | -0.836740 | -0.695952 | -1.271727 | -0.450149 | -1.234825 | -0.235168 | ... | 1.064366 | -0.711015 | -0.276522 | 0.945700 | 0.733221 | 0.227906 | 0.780702 | -0.817432 | XYZ | 2 |
| 2996 | -0.611947 | -0.484497 | 0.390457 | 0.072502 | 1.161350 | -0.420848 | 1.256947 | 1.006416 | 1.174028 | -0.235168 | ... | -0.538022 | 0.007720 | 0.712764 | 0.334387 | -1.870853 | -2.887961 | -3.359953 | -1.471246 | XYZ | 2 |
| 2997 | -0.968255 | -0.883025 | 0.153989 | 0.599219 | 1.955205 | 0.702022 | -0.571010 | 1.787345 | -0.092577 | 3.391365 | ... | -2.042102 | 0.106871 | 1.340272 | -2.313874 | 0.697965 | 0.238777 | 0.005441 | 0.982994 | XYZ | 2 |
| 2998 | -0.951836 | -0.808981 | -0.635262 | -0.836083 | 0.253127 | 0.039529 | -0.677641 | 0.234261 | -0.751212 | -0.235168 | ... | -0.315926 | 0.510587 | -0.905646 | 0.490320 | 0.656834 | 0.923382 | 0.268773 | 0.382852 | XYZ | 2 |
| 2999 | -0.866453 | -0.231878 | 1.130572 | 1.520973 | -1.004930 | 0.174273 | -0.119098 | -0.730932 | -0.258387 | -0.235168 | ... | -0.186269 | 0.483525 | 0.746580 | 0.774405 | 0.597423 | 0.347855 | -0.133989 | -0.526454 | XYZ | 2 |
3000 rows × 123 columns
Save a specific feature into a new variable.
[92]:
donor = mm_object1.save_feature('donor')
mm_object1.drop_variables('donor')
[93]:
file_number = mm_object1.save_feature('file_number')
mm_object1.drop_variables('file_number')
DMAP#
Run DMAP, or alternatively UMAP.
[94]:
mm_object1.dmap(5,10,1,'euclidean')
[95]:
#mm_object1.umap(nn=5,mdist=0.3,met='euclidean')
Feature Importance#
Calculate the importance of features in the dataset:
[96]:
fi_x=mm_object1.feature_importance('x','y')
print(fi_x)
length of data for training: 2400
length of data for testing: 600
r² Score: 0.9208301665560771
index1 importance_normalized percentage_importance
0 Area_Inspire(M07__Ch07) 0.044624 1.869693
1 Width_M10 0.051926 2.175636
2 Major_Axis_MC 0.053932 2.259647
3 Length_M10 0.066301 2.777915
4 Perimeter_M01 0.072882 3.053641
5 Area_M10 0.082522 3.457550
6 Height_M10 0.104980 4.398503
7 Area_M07 0.112134 4.698258
8 Area_Morphology(M07__Ch07) 0.305888 12.816248
9 Area_System(M07__Ch07__39) 1.000000 41.898441
Plot the feature importance, renaming one of the features in advance as an example:
[97]:
fi_x['index1'] = fi_x['index1'].replace({'Aspect_Ratio_M03': 'Area Ratio CXCR4'})
mm_object1.plot_feature_importance(fi_x,'./example/png/feature_importance_x.png',15,7)
Plot successfully saved to ./example/png/feature_importance_x.png
Calculate the feature importance for the values of the y coordinate
[98]:
fi_y=mm_object1.feature_importance('y','x')
print(fi_y)
mm_object1.plot_feature_importance(fi_y,'./example/png/feature_importance_y.png')
length of data for training: 2400
length of data for testing: 600
r² Score: 0.8355020516609143
index1 importance_normalized \
0 Length_M03 0.101797
1 Area_M05 0.126089
2 Major_Axis_M02 0.131002
3 Lobe_Count_Morphology(M07__Ch07)_Ch07 0.140793
4 Height_M04 0.201060
5 Area_M12 0.284924
6 Aspect_Ratio_M03 0.360203
7 Width_M03 0.389692
8 Area_M03 0.520689
9 Height_M03 1.000000
percentage_importance
0 2.167009
1 2.684136
2 2.788721
3 2.997145
4 4.280088
5 6.065362
6 7.667887
7 8.295619
8 11.084251
9 21.287652
Plot successfully saved to ./example/png/feature_importance_y.png
Clustering#
Cluster the dataset using either K-means, Gaussian Mixture Models, or HDBSCAN
[99]:
mm_object1.cluster_kmeans(4,'DMAP 1','DMAP 2')
mm_object1.cluster_gmm(5,42,'DMAP 1','DMAP 2')
mm_object1.cluster_hdbscan(3,'DMAP 1','DMAP 2')
Reattach the donor variable to the original dataset to preserve its association with the other features.
[100]:
mm_object1.concat_variables(donor,file_number)
[100]:
| Area F Actin | Area Nucleus | Area_M03 | Area_M04 | Area_M05 | Area_M06 | Area_M07 | Area_M08 | Area_M09 | Area_M10 | ... | Aspect_Ratio_Inspire(M07__Ch07) | Aspect_Ratio_Inspire(M01__Ch01) | Shape_Ratio_Inspire(M02__Ch02) | x | y | kmeans_cluster | GMM_cluster | hdbscan_cluster | donor | file_number | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 1.337076 | 1.625742 | 0.897175 | 1.463912 | -0.628185 | -0.140131 | -0.261273 | -0.125493 | 0.123897 | -0.235168 | ... | -0.702550 | -0.961786 | 0.549558 | 12.690500 | -3.765087 | 3 | 1 | 10 | ABC | 1 |
| 1 | 1.957742 | 1.799961 | 2.223853 | 2.425170 | -1.065478 | 0.965897 | 0.601929 | 0.120193 | 1.367473 | -0.235168 | ... | -1.402301 | -2.109929 | -0.640646 | 8.297702 | -6.612311 | 3 | 3 | 10 | ABC | 1 |
| 2 | 0.713126 | 0.863530 | -0.432575 | -0.037230 | 1.443909 | -0.089601 | 0.287114 | 0.839701 | 0.123897 | -0.235168 | ... | 0.738303 | 1.016538 | 1.072670 | 12.378029 | 3.824110 | 0 | 2 | 10 | ABC | 1 |
| 3 | 1.520976 | 1.721562 | 1.041512 | -0.862419 | -0.123617 | 1.527333 | -0.748728 | -0.318532 | 0.883860 | -0.235168 | ... | 0.756964 | -0.230971 | -0.817432 | 13.908522 | 6.700144 | 1 | 2 | 10 | ABC | 1 |
| 4 | 1.156458 | 0.532512 | 0.141705 | 0.691394 | -1.065478 | 1.577862 | 0.322658 | 0.330781 | 0.653568 | -0.235168 | ... | -0.414427 | 0.415230 | -1.617622 | 13.321676 | -0.480107 | 3 | 1 | 10 | ABC | 1 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 2995 | -1.355761 | -1.379551 | 0.083355 | 0.199792 | -0.836740 | -0.695952 | -1.271727 | -0.450149 | -1.234825 | -0.235168 | ... | 0.227906 | 0.780702 | -0.817432 | 17.468170 | 2.318774 | 1 | 2 | 10 | XYZ | 2 |
| 2996 | -0.611947 | -0.484497 | 0.390457 | 0.072502 | 1.161350 | -0.420848 | 1.256947 | 1.006416 | 1.174028 | -0.235168 | ... | -2.887961 | -3.359953 | -1.471246 | 2.973614 | -2.454584 | 3 | 3 | 6 | XYZ | 2 |
| 2997 | -0.968255 | -0.883025 | 0.153989 | 0.599219 | 1.955205 | 0.702022 | -0.571010 | 1.787345 | -0.092577 | 3.391365 | ... | 0.238777 | 0.005441 | 0.982994 | 6.217534 | 0.889777 | 2 | 1 | 10 | XYZ | 2 |
| 2998 | -0.951836 | -0.808981 | -0.635262 | -0.836083 | 0.253127 | 0.039529 | -0.677641 | 0.234261 | -0.751212 | -0.235168 | ... | 0.923382 | 0.268773 | 0.382852 | 16.091002 | 5.345477 | 1 | 2 | 10 | XYZ | 2 |
| 2999 | -0.866453 | -0.231878 | 1.130572 | 1.520973 | -1.004930 | 0.174273 | -0.119098 | -0.730932 | -0.258387 | -0.235168 | ... | 0.347855 | -0.133989 | -0.526454 | 13.406321 | -2.877094 | 3 | 1 | 10 | XYZ | 2 |
3000 rows × 128 columns
Interactive Plots#
Examples of various visualizations. Create a plot using a categaorical color mapper to differentiate between donors.
[101]:
mm_object1.cat_plot(
feature='donor',
subs=['ABL','XYZ'],
colors=['blue','red'],
outputf='test_cat_plot.html',
fig_width=700,
fig_height=700,
fig_title='Simple Cat Plot - Donors',
label_x='DensMAP 1',
label_y='DensMAP 2',
range_x=[-30, 40],
range_y=[-35, 35],
hover_tooltips=[
("Donor", "donor"),
("ID", "ID"),
("Area Ch05", "Area_M05"),
("X Value", "x"),
("Y Value", "y"),
],
show_legend=True,
point_size=12,
point_alpha=0.8,
show_axes=False,
title_align='center'
)
[102]:
mm_object1.lin_plot(
outputf='test_lin_plot.html',
feature='Area_M05',
colors='Plasma256',
fig_width=700,
fig_height=700,
fig_title='Simple Linear Plot - Area_M05',
label_x='DensMAP 1',
label_y='DensMAP 2',
range_x=[-30, 40],
range_y=[-35, 35],
hover_tooltips=[
("Donor", "donor"),
("ID", "ID"),
("Area Ch05", "Area_M05"),
("X-Value", "x"),
("Y-Value", "y")
],
show_legend=False,
point_size=12,
point_alpha=0.8,
show_axes=False,
title_align='center'
)
Plot the values with a linear color mapper to represent the data on a continous color scale.
[103]:
colors = ['red', 'blue', 'orange', 'yellow', 'pink']
mm_object1.lin_plot(
feature='GMM_cluster',
colors=colors,
outputf='cluster.html',
fig_width=700,
fig_height=700,
fig_title='GMM-Cluster',
label_x='DensMAP 1',
label_y='DensMAP 2',
range_x=[-30, 40],
range_y=[-35, 35],
show_legend=True,
point_size=10,
point_alpha=0.6,
show_axes=True,
title_align='center'
)
Plot the five clusters.
[104]:
colors = ['red', 'blue', 'orange', 'yellow', 'pink']
rename_dict = {
0: 'cluster 0',
1: 'cluster A',
2: 'cluster H\u2082O\u2082',
3: 'cluster 4',
4: 'cluster 5'
}
mm_object1.update_column_values('GMM_cluster', rename_dict)
mm_object1.cat_plot(
feature='GMM_cluster',
subs=['cluster 0','cluster A','cluster H\u2082O\u2082','cluster 4','cluster 5'],
colors=colors,
outputf='cluster_new_labels.html',
fig_width=800,
fig_height=800,
fig_title='Cluster - New Legend',
label_x='DensMAP 1',
label_y='DensMAP 2',
range_x=[-30, 50],
range_y=[-35, 35],
hover_tooltips=[
("Donor", "donor"),
("ID", "ID"),
("Area Ch05", "Area_M05"),
("Cluster", "GMM_cluster"),
("X-Value", "x"),
("Y-Value", "y"),
],
show_legend=True,
point_size=10,
point_alpha=0.8,
show_axes=True,
title_align='center'
)
Cell Plot#
plot clusters with given IDs:
kmeans
[109]:
mm_object1.cell_plot(cluster_column='kmeans_cluster',
top_clusters=4,
palette=p,
ID=[1,100,556,600,2456,2589,1800],
x_label='X',
y_label='Y',
png=True,
svg=False,
name='./example/cell_plot_example_kmeans')
plot saved as: ./example/cell_plot_example_kmeans.png
Save dataset#
[108]:
mm_object1.save_xlsx('./example/excel.xlsx')
mm_object1.save_csv('./example/csvtest.CSV')
DataFrame successfully saved to ./example/excel.xlsx
DataFrame successfully saved to ./example/csvtest.CSV