Description | GeneRatio | BgRatio | pvalue | p.adjust | qvalue | geneID | Count | group | |
ID | |||||||||
GO:0002455 | humoral immune response mediated by circulatin... | 22/178 | 150/18670 | 19.365993 | 16.222197 | 16.298589 | HLA-DQB1/CD55/IGHM/PTPRC/TRBC2/IGHG2/IGKV3-20/... | 22 | B6_up |
GO:0006958 | complement activation, classical pathway | 20/178 | 137/18670 | 17.588789 | 14.989062 | 15.065454 | CD55/IGHM/TRBC2/IGHG2/IGKV3-20/IGHV4-34/IGHV3-... | 20 | B6_up |
GO:0006956 | complement activation | 20/178 | 175/18670 | 15.453684 | 13.008859 | 13.085251 | CD55/IGHM/TRBC2/IGHG2/IGKV3-20/IGHV4-34/IGHV3-... | 20 | B6_up |
GO:0038096 | Fc-gamma receptor signaling pathway involved i... | 18/178 | 139/18670 | 14.916693 | 12.675988 | 12.752379 | PTPRC/LYN/IGHG2/IGKV3-20/IGHV4-34/IGHV3-30/IGL... | 18 | B6_up |
GO:0002673 | regulation of acute inflammatory response | 18/178 | 159/18670 | 13.871614 | 11.817674 | 11.894066 | HLA-E/CD55/IGHG2/IGKV3-20/IGHV4-34/IGHV3-30/IG... | 18 | B6_up |
首先我們可以借助 DotPlot
的類方法parse_from_tidy_data
對數(shù)據(jù)進行封裝,然后直接調(diào)用plot
函數(shù)進行繪圖。當然,你也可以通過DotPlot
的構(gòu)造函數(shù)__init__()
來實例化DotPlot
對象。
new_keys = {'item_key': 'Description','group_key': 'group','sizes_key': 'Count'} dp = dotplot.DotPlot.parse_from_tidy_data(data, **new_keys) sct = dp.plot(size_factor=10, cmap='Reds') # 通過size_factor 調(diào)節(jié)圖中點的大小
dp = dotplot.DotPlot.parse_from_tidy_data(data, item_key='Description', group_key='group', sizes_key='Count') # 該效果完全同上,這是python語言特性 sct = dp.plot(size_factor=10, cmap='Reds')
我們可以通過color_key
指定data
中的列做顏色映射。
new_keys = {'item_key': 'Description','group_key': 'group','sizes_key': 'Count','color_key': 'pvalue'} dp = dotplot.DotPlot.parse_from_tidy_data(data, **new_keys) sct = dp.plot(size_factor=10, cmap='Reds', cluster_row=True)
可以通過circle_key
增加一列作為虛線圓圈的映射。
DEFAULT_CLUSTERPROFILE_KEYS = { 'item_key': 'Description', 'group_key': 'group', 'sizes_key': 'Count', 'color_key': 'pvalue', 'circle_key': 'qvalue' } dp = dotplot.DotPlot.parse_from_tidy_data(data, **DEFAULT_CLUSTERPROFILE_KEYS) sct = dp.plot(size_factor=10, cmap='Reds', cluster_row=True)
當然,更多的參數(shù)我們可以通過signature來查看,我對這些參數(shù)都做了類型注釋,應該是通俗易懂的:
?dp.plot
Signature: dp.plot( size_factor:float=15, vmin:float=0, vmax:float=None, path:Union[os.PathLike, NoneType]=None, cmap:Union[str, matplotlib.colors.Colormap]='Reds', cluster_row:bool=False, cluster_col:bool=False, cluster_kws:Union[Dict, NoneType]=None, **kwargs, ) Docstring: :param size_factor: `size factor` * `value` for the actually representation of scatter size in the final figure :param vmin: `vmin` in `matplotlib.pyplot.scatter` :param vmax: `vmax` in `matplotlib.pyplot.scatter` :param path: path to save the figure :param cmap: color map supported by matplotlib :param kwargs: dot_title, circle_title, colorbar_title, dot_color, circle_color other kwargs are passed to `matplotlib.Axes.scatter` :param cluster_row, whether to cluster the row :param cluster_col, whether to cluster the col :param cluster_kws, key args for cluster, including `cluster_method`, `cluster_metric`, 'cluster_n' :return:
因此,我們可以通過關(guān)鍵字參數(shù)修改圖例中的部分組件:
sct = dp.plot(size_factor=10, cmap='Reds', cluster_row=True, dot_title = 'Count', circle_title='-log10(qvalue)', colorbar_title = '-log10(pvalue)')
dotplot在數(shù)據(jù)可視化中是一個強有力的展示方式,選擇一個合適的可視化方式勝過千言萬語
最后,最適合的可視化方式是最直觀、最簡潔的,不是炫技,別被花里胡哨的可視化所迷住雙眼而忽略了信息的傳達。
到此這篇關(guān)于教你怎么用python繪制dotplot的文章就介紹到這了,更多相關(guān)python繪制dotplot內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!