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#
[303]:
from morphomapping import MM
Load object#
[304]:
mm_object1= MM()
Convert files#
[305]:
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')
[307]:
mm_object1.get_df()
[307]:
| 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
[308]:
mm_object1.get_features()
[308]:
['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.
[309]:
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)
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)
Concatenate object 1 and object 2#
[311]:
df = mm_object2.get_df()
mm_object1.concat_df(df)
mm_object1.get_df()
[311]:
| 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 | 131.666672 | 102.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 | 152.666672 | 106.444443 | 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 | 110.555557 | 82.555557 | 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 | 137.888885 | 104.444443 | 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 | 125.555557 | 74.111115 | 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 | 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 |
| 13860 | 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 |
| 13868 | 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 |
| 13887 | 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 |
| 13917 | 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.
[312]:
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',
]
[313]:
mm_object1.drop_variables(*d_features)
mm_object1.get_features()
[313]:
['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.
[314]:
label_mapping = {'Area_M01': 'Area F Actin', 'Area_M02': 'Area Nucleus'}
mm_object1.rename_variables(label_mapping)
mm_object1.get_features()
[314]:
['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']
Normalization#
Apply Min-Max normalization to a specific part of the dataset.
[315]:
mm_object1.minmax_norm('Area F Actin','Shape_Ratio_Inspire(M02__Ch02)')
Save a specific feature into a new variable.
[316]:
donor = mm_object1.save_feature('donor')
mm_object1.drop_variables('donor')
[317]:
file_number = mm_object1.save_feature('file_number')
mm_object1.drop_variables('file_number')
DMAP#
Run DMAP, or alternatively UMAP.
[318]:
mm_object1.dmap(5,10,1,'euclidean')
Feature Importance#
Calculate the importance of features in the dataset:
[319]:
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.9169140808004912
index1 importance_normalized \
0 Lobe_Count_Inspire(M01__Ch01)_Ch01 0.111771
1 Aspect_Ratio_M05 0.120856
2 Area_Inspire(M07__Ch07) 0.128410
3 Width_M03 0.138547
4 Width_M05 0.180394
5 Area_M12 0.187849
6 Area_M05 0.209508
7 Area_M03 0.388043
8 Lobe_Count_Morphology(M07__Ch07)_Ch07 0.754339
9 Aspect_Ratio_M03 1.000000
percentage_importance
0 2.118421
1 2.290600
2 2.433780
3 2.625900
4 3.419038
5 3.560338
6 3.970839
7 7.354637
8 14.297111
9 18.953162
Plot the feature importance, renaming one of the features in advance as an example:
[320]:
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)
An error occurred while saving to png: [Errno 2] No such file or directory: './example/png/feature_importance_x.png'
Calculate the feature importance for the values of the y coordinate.
[321]:
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.877517360023235
index1 importance_normalized \
0 Area_M10 0.068556
1 Aspect_Ratio_M03 0.072802
2 Width_M10 0.076875
3 Aspect_Ratio_M10 0.078655
4 Shape_Ratio_Inspire(M07__Ch07) 0.081433
5 Major_Axis_MC 0.081778
6 Perimeter_M01 0.084388
7 Area_M07 0.116970
8 Area_Morphology(M07__Ch07) 0.535184
9 Area_System(M07__Ch07__39) 1.000000
percentage_importance
0 1.943117
1 2.063465
2 2.178911
3 2.229365
4 2.308108
5 2.317879
6 2.391849
7 3.315352
8 15.168975
9 28.343488
An error occurred while saving to png: [Errno 2] No such file or directory: './example/png/feature_importance_y.png'
Clustering#
Cluster the dataset using either K-means, Gaussian Mixture Models, or HDBSCAN.
[322]:
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.
[323]:
mm_object1.concat_variables(donor,file_number)
[323]:
| 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 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ID | |||||||||||||||||||||
| 6 | 0.477444 | 0.471466 | 0.573610 | 0.644156 | 0.087131 | 0.447148 | 0.313243 | 0.377970 | 0.410785 | 0.00 | ... | 0.686934 | 0.611811 | 0.722222 | 11.887270 | 0.777437 | 2 | 3 | 193 | ABC | 1 |
| 7 | 0.619549 | 0.497406 | 0.837508 | 0.833766 | 0.000000 | 0.596958 | 0.448057 | 0.408207 | 0.624901 | 0.00 | ... | 0.555405 | 0.408304 | 0.325581 | 21.417612 | 5.581223 | 2 | 3 | 169 | ABC | 1 |
| 30 | 0.334586 | 0.357977 | 0.309102 | 0.348052 | 0.500000 | 0.453992 | 0.398890 | 0.496760 | 0.410785 | 0.00 | ... | 0.957763 | 0.962465 | 0.896552 | 0.911417 | -5.084484 | 0 | 3 | 87 | ABC | 1 |
| 36 | 0.519549 | 0.485733 | 0.602321 | 0.185281 | 0.187668 | 0.673004 | 0.237113 | 0.354212 | 0.541634 | 0.00 | ... | 0.961271 | 0.741346 | 0.266667 | 3.290637 | -5.926403 | 1 | 2 | -1 | ABC | 1 |
| 41 | 0.436090 | 0.308690 | 0.423335 | 0.491775 | 0.000000 | 0.679848 | 0.404441 | 0.434125 | 0.501983 | 0.00 | ... | 0.741091 | 0.855884 | 0.000000 | 8.890261 | -0.130765 | 1 | 3 | 67 | ABC | 1 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 13859 | 0.135338 | 0.171855 | 0.411729 | 0.394805 | 0.045576 | 0.371863 | 0.155432 | 0.338013 | 0.176844 | 0.00 | ... | 0.861827 | 0.920663 | 0.266667 | 11.097633 | -12.040171 | 1 | 2 | 101 | XYZ | 2 |
| 13860 | 0.475940 | 0.438392 | 0.472816 | 0.369697 | 0.443700 | 0.409125 | 0.550357 | 0.517279 | 0.591594 | 0.00 | ... | 0.276153 | 0.186740 | 0.048780 | 16.586107 | 8.940875 | 2 | 4 | 24 | XYZ | 2 |
| 13868 | 0.312782 | 0.319715 | 0.425779 | 0.473593 | 0.601877 | 0.561217 | 0.264869 | 0.613391 | 0.373513 | 0.34 | ... | 0.863870 | 0.783250 | 0.866667 | 7.170313 | 1.115400 | 1 | 1 | -1 | XYZ | 2 |
| 13887 | 0.320301 | 0.341764 | 0.268784 | 0.190476 | 0.262735 | 0.471483 | 0.248216 | 0.422246 | 0.260111 | 0.00 | ... | 0.992552 | 0.829925 | 0.666667 | 1.631529 | -1.300768 | 0 | 0 | 31 | XYZ | 2 |
| 13917 | 0.359399 | 0.513619 | 0.620037 | 0.655411 | 0.012064 | 0.489734 | 0.335448 | 0.303456 | 0.344964 | 0.00 | ... | 0.884373 | 0.758536 | 0.363636 | 14.251678 | 1.163582 | 2 | 3 | 185 | XYZ | 2 |
3000 rows × 128 columns
Plots#
Examples of various visualizations.
Create a plot using a categorical color mapper to differentiate between donors.
[324]:
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'
)
Plot the values with a linear color mapper to represent the data on a continuous color scale.
[325]:
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 five clusters.
[326]:
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 clusters with a new legend.
[327]:
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'
)
Save dataset#
[328]:
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