简体   繁体   English

如何在 python/pandas 中使用 seaborn 绘制基于二部文本的图形数据的频率分布

[英]How to plot frequency distribution using seaborn in python/pandas for a bipartite text based graph data

I have a dataframe with 70k rows, & it looks like this:我有一个包含 70k 行的数据框,它看起来像这样:

mirna   gene_id
osa-miR2873a    Os01g0100100
osa-miR169d Os01g0100100
osa-miR169a Os01g0100100
osa-miR396a-3p  Os01g0100200
osa-miR396b-3p  Os01g0100200
...             ...

I am using matplotlib & seaborn for plotting the data.我正在使用 matplotlib 和 seaborn 来绘制数据。 & I have managed to calculate the frequency using the value_counts() pandas function. & 我已经设法使用value_counts()熊猫函数计算频率。

I need to plot a graph to show how many times a certain range of frequencies of 'mirna' occurences appear in the dataset.我需要绘制一个图表来显示特定范围的“mirna”出现频率在数据集中出现的次数。 For example how many 'mirna' have 1-5 mirna-gene_id pairs, or 5-15 pairs, or 15-30 pairs & so on...例如,有多少“mirna”有 1-5 对 mirna-gene_id 对,或 5-15 对,或 15-30 对等等......

So essentially the plot should show that (1-5) pairs occur x-times, (5-15) pairs occur y-times etc.If I can plot the values in sorted order, all the more better.所以基本上该图应该显示 (1-5) 对出现 x 次,(5-15) 对出现 y 次等。如果我可以按排序顺序绘制值,那就更好了。 I have tried sns.distplot() but it is not working for me.我试过 sns.distplot() 但它对我不起作用。

Any clues?有什么线索吗? Thanks.谢谢。

You could groupby mirna and summarize by gene_id count.您可以按 mirna 分组并按gene_id 计数进行汇总。 Then you could just do a histogram of that.然后你可以做一个直方图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 pandas 和 seaborn 在一张折线图上 plot 两列? - How to plot two columns on one line graph using pandas and seaborn? 在 python 中使用 Seaborn 在配对图中分布 - Distribution in Pair Plot using Seaborn in python 使用python / pandas / seaborn将分类数据绘制成相对频率的单个条形图 - Plotting categorical data into a single bar plot of relative frequency with python/pandas/seaborn 如何使用python中的pandas查找相对于特定列的数据帧中的频率分布 - how to find frequency distribution in a data frame with respect to a particular column using pandas in python 如何在python中绘制角频率分布曲线 - How to plot the angle frequency distribution curve in python Python:使用熊猫为二分图创建边列表 - Python: create edge list for bipartite graph using pandas 如何使用facetgrid绘制Seaborn中的Pandas多标签数据散点图? - How to plot Pandas multilabel data scatterplots in Seaborn using facetgrid? Seaborn 分布图线图显示振铃 - Seaborn distribution plot line graph shows ringing 使用 Python 解析频率分布的嵌套行文本文档 Plot - Parsing Nested Row Text Document for Frequency Distribution Plot with Python 在python中使用seaborn在分布图上显示峰度,偏度等指标 - show metrics like kurtosis, skewness on distribution plot using seaborn in python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM