# add seg maskseg_mask_path=str(common_path)+'exemplar_001/qc/s3seg/unmicst-exemplar-001/cellOutlines.ome.tif'sm.pl.image_viewer(image_path,adata,seg_mask=seg_mask_path,overlay='phenotype',point_color='white',point_size=10)
12
# Visualize heatmap of cell typessc.pl.matrixplot(adata,var_names=adata.var.index,groupby='phenotype',dendrogram=True,use_raw=False,cmap="vlag",standard_scale='var')
# Map user defined colorscolors={'ASMA+ cells':'#8AC926','Myeloid':"#E9D8A6",'NK cells':"#0A9396",'Neutrophils':"#CA6702",'Other Immune cells':'#001219','Treg':"#005F73",'Tumor':"#9B2226",'Unknown':'#BCB8B1'}
OpeningNapari;Addshapelayers(onleft)todrawROI's. Rename the shape layer to give a name to your ROI Multiple shape layers are supported ROI'sshouldnotoverlapCloseNaparitosaveROI's.Identifying cells within selected ROI's/opt/anaconda3/envs/scimap/lib/python3.9/site-packages/scimap/plotting/_addROI_image.py:364:SettingWithCopyWarning:AvalueistryingtobesetonacopyofaslicefromaDataFrame.Tryusing.loc[row_indexer,col_indexer]=valueinsteadSeethecaveatsinthedocumentation:https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copyinside['ROI_internal']=all_rois[all_rois['id']==roi_id]['ROI'][roi_id]/opt/anaconda3/envs/scimap/lib/python3.9/site-packages/scimap/plotting/_addROI_image.py:364:SettingWithCopyWarning:AvalueistryingtobesetonacopyofaslicefromaDataFrame.Tryusing.loc[row_indexer,col_indexer]=valueinsteadSeethecaveatsinthedocumentation:https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copyinside['ROI_internal']=all_rois[all_rois['id']==roi_id]['ROI'][roi_id]/opt/anaconda3/envs/scimap/lib/python3.9/site-packages/scimap/plotting/_addROI_image.py:364:SettingWithCopyWarning:AvalueistryingtobesetonacopyofaslicefromaDataFrame.Tryusing.loc[row_indexer,col_indexer]=valueinsteadSeethecaveatsinthedocumentation:https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copyinside['ROI_internal']=all_rois[all_rois['id']==roi_id]['ROI'][roi_id]/opt/anaconda3/envs/scimap/lib/python3.9/site-packages/scimap/plotting/_addROI_image.py:364:SettingWithCopyWarning:AvalueistryingtobesetonacopyofaslicefromaDataFrame.Tryusing.loc[row_indexer,col_indexer]=valueinsteadSeethecaveatsinthedocumentation:https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copyinside['ROI_internal']=all_rois[all_rois['id']==roi_id]['ROI'][roi_id]/opt/anaconda3/envs/scimap/lib/python3.9/site-packages/scimap/plotting/_addROI_image.py:364:SettingWithCopyWarning:AvalueistryingtobesetonacopyofaslicefromaDataFrame.Tryusing.loc[row_indexer,col_indexer]=valueinsteadSeethecaveatsinthedocumentation:https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copyinside['ROI_internal']=all_rois[all_rois['id']==roi_id]['ROI'][roi_id]/opt/anaconda3/envs/scimap/lib/python3.9/site-packages/scimap/plotting/_addROI_image.py:364:SettingWithCopyWarning:AvalueistryingtobesetonacopyofaslicefromaDataFrame.Tryusing.loc[row_indexer,col_indexer]=valueinsteadSeethecaveatsinthedocumentation:https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copyinside['ROI_internal']=all_rois[all_rois['id']==roi_id]['ROI'][roi_id]
12
# check ROI cell countadata.obs['ROI'].value_counts()
Other 8075
CD57-high 2115
CD57-low 980
Name: ROI, dtype: int64
1234
# Add ROI individuallyadata=sm.pl.addROI_image(image_path,adata,overwrite=True,label='ROI_individual')
OpeningNapari;Addshapelayers(onleft)todrawROI's. Rename the shape layer to give a name to your ROI Multiple shape layers are supported ROI'sshouldnotoverlapCloseNaparitosaveROI's.Identifying cells within selected ROI's/opt/anaconda3/envs/scimap/lib/python3.9/site-packages/scimap/plotting/_addROI_image.py:364:SettingWithCopyWarning:AvalueistryingtobesetonacopyofaslicefromaDataFrame.Tryusing.loc[row_indexer,col_indexer]=valueinsteadSeethecaveatsinthedocumentation:https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copyinside['ROI_internal']=all_rois[all_rois['id']==roi_id]['ROI'][roi_id]/opt/anaconda3/envs/scimap/lib/python3.9/site-packages/scimap/plotting/_addROI_image.py:364:SettingWithCopyWarning:AvalueistryingtobesetonacopyofaslicefromaDataFrame.Tryusing.loc[row_indexer,col_indexer]=valueinsteadSeethecaveatsinthedocumentation:https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copyinside['ROI_internal']=all_rois[all_rois['id']==roi_id]['ROI'][roi_id]/opt/anaconda3/envs/scimap/lib/python3.9/site-packages/scimap/plotting/_addROI_image.py:364:SettingWithCopyWarning:AvalueistryingtobesetonacopyofaslicefromaDataFrame.Tryusing.loc[row_indexer,col_indexer]=valueinsteadSeethecaveatsinthedocumentation:https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copyinside['ROI_internal']=all_rois[all_rois['id']==roi_id]['ROI'][roi_id]/opt/anaconda3/envs/scimap/lib/python3.9/site-packages/scimap/plotting/_addROI_image.py:364:SettingWithCopyWarning:AvalueistryingtobesetonacopyofaslicefromaDataFrame.Tryusing.loc[row_indexer,col_indexer]=valueinsteadSeethecaveatsinthedocumentation:https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copyinside['ROI_internal']=all_rois[all_rois['id']==roi_id]['ROI'][roi_id]/opt/anaconda3/envs/scimap/lib/python3.9/site-packages/scimap/plotting/_addROI_image.py:364:SettingWithCopyWarning:AvalueistryingtobesetonacopyofaslicefromaDataFrame.Tryusing.loc[row_indexer,col_indexer]=valueinsteadSeethecaveatsinthedocumentation:https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copyinside['ROI_internal']=all_rois[all_rois['id']==roi_id]['ROI'][roi_id]/opt/anaconda3/envs/scimap/lib/python3.9/site-packages/scimap/plotting/_addROI_image.py:364:SettingWithCopyWarning:AvalueistryingtobesetonacopyofaslicefromaDataFrame.Tryusing.loc[row_indexer,col_indexer]=valueinsteadSeethecaveatsinthedocumentation:https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copyinside['ROI_internal']=all_rois[all_rois['id']==roi_id]['ROI'][roi_id]/opt/anaconda3/envs/scimap/lib/python3.9/site-packages/scimap/plotting/_addROI_image.py:364:SettingWithCopyWarning:AvalueistryingtobesetonacopyofaslicefromaDataFrame.Tryusing.loc[row_indexer,col_indexer]=valueinsteadSeethecaveatsinthedocumentation:https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copyinside['ROI_internal']=all_rois[all_rois['id']==roi_id]['ROI'][roi_id]
12
# check number of cellsadata.obs['ROI_individual'].value_counts()
# Scatter plot to show the differnt ROI'simportpandasaspdimportplotly.expressaspximportplotly.ioaspiopio.renderers.default='browser'defplotly(adata,phenotype,image_id=None,x='X_centroid',y='Y_centroid',size=2,**kwargs):ifimage_idisnotNone:adata=adata[adata.obs['imageid']==image_id]data=pd.DataFrame({'x':adata.obs[x],'y':adata.obs[y],'col':adata.obs[phenotype]})data=data.sort_values(by=['col'])fig=px.scatter(data,x="x",y="y",color="col",**kwargs)fig.update_traces(marker=dict(size=size),selector=dict(mode='markers'),hoverlabel=dict(namelength=-1))fig.update_yaxes(autorange="reversed",tickformat='g')fig.update_xaxes(tickformat='g')fig.update_layout({'plot_bgcolor':'rgba(0, 0, 0, 0)','paper_bgcolor':'rgba(0, 0, 0, 0)'})returnfigplotly(adata,phenotype='ROI_individual',image_id=None,x='X_centroid',y='Y_centroid',size=10)