stacked_barplot
Short Description
sm.pl.stacked_barplot
: The function allows users to generate a stacked bar plot of a categorical column.
The function can generate the plots using matplotlib and Plotly libraries. Plotly is browser based and so
it can be used for interactive data exploration.
Function
stacked_barplot(adata, x_axis='imageid', y_axis='phenotype', subset_xaxis=None, subset_yaxis=None, order_xaxis=None, order_yaxis=None, method='percent', plot_tool='matplotlib', matplotlib_cmap=None, matplotlib_bbox_to_anchor=(1, 1.02), matplotlib_legend_loc=2, return_data=False, **kwargs)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
adata |
AnnData Object |
required | |
x_axis |
string
|
Column name of the data that need to be plotted in the x-axis. |
'imageid'
|
y_axis |
string
|
Column name of the data that need to be plotted in the y-axis. |
'phenotype'
|
subset_xaxis |
list
|
Subset x-axis before plotting. Pass in a list of categories. eg- subset_xaxis = ['ROI_1', 'ROI_5'] |
None
|
subset_yaxis |
list
|
Subset y-axis before plotting. Pass in a list of categories. eg- subset_yaxis = ['Celltype_A', 'Celltype_B'] |
None
|
order_xaxis |
list
|
Order the x-axis of the plot as needed. Pass in a list of categories. eg- order_xaxis = ['ROI_5', 'ROI_1'] The default is None and will be plotted based on alphabetic order. Please note that if you change the order, pass all categories, failure to do so will generate NaN's. |
None
|
order_yaxis |
list
|
Order the y-axis of the plot as needed. Pass in a list of categories. eg- order_yaxis = ['Celltype_B', 'Celltype_A'] The default is None and will be plotted based on alphabetic order. Please note that if you change the order, pass all categories, failure to do so will generate NaN's. |
None
|
method |
string
|
Available options: 'percent' and 'absolute'.
1) Use Percent to plot the percent proportion. |
'percent'
|
plot_tool |
string
|
Available options: 'matplotlib' and 'plotly'. |
'matplotlib'
|
matplotlib_cmap |
string
|
Colormap to select colors from. If string, load colormap with that name from matplotlib. |
None
|
matplotlib_bbox_to_anchor |
tuple
|
Bounding box argument used along with matplotlib_legend_loc to control the legend location when using the matplotlib method. |
(1, 1.02)
|
matplotlib_legend_loc |
int
|
Location of legend used along with matplotlib_bbox_to_anchor to control the legend location when using the matplotlib method. |
2
|
return_data |
bool
|
When True, return the data used for plotting. |
False
|
**kwargs |
Additional keyword arguments passed to: |
{}
|
Returns:
Type | Description |
---|---|
Stacked bar plot. If return_data is set to |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
|
Source code in scimap/plotting/_stacked_barplot.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
|