In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to draw with Python". In daily operation, I believe many people have doubts about how to draw with Python. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts about "how to draw with Python". Next, please follow the editor to study!
one。 Data preparation
Data description
Sample data, in which the data are all virtual data and have nothing to do with the actual biological process
File name: dataset_volcano.txt
The sequence is gene (gene), multiple of difference (logFC), and P value of t-test (P.Value).
two。 Map the volcano
Step 1: import data:
Import pandas as pd # Data analysisimport numpy as np # Scientific computingimport seaborn as sns # Statistical visualization# read data df = pd.read_csv ('. / dataset_volcano.txt', sep='\ t') result = pd.DataFrame () result ['x'] = df ['logFC'] result [' y'] = df ['P.Value'] result ['-log10 (pvalue)'] =-df ['P.Value'] .apply (np.log10)
Step2: setting threshold
# set the threshold for pvalue and logFC cut_off_pvalue = 0.0000001cut_off_logFC = 1
Step3: setting grouping
# grouped into up, normal, downresult.loc [(result.x > cut_off_logFC) & (result.y)
< cut_off_pvalue),'group'] = 'up'result.loc[(result.x< -cut_off_logFC )&(result.y < cut_off_pvalue),'group'] = 'down'result.loc[(result.x>=-cut_off_logFC) & (result.x= cut_off_pvalue), 'group'] =' normal'
Step4: drawing scatter plot
# drawing scatter ax = sns.scatterplot (x = "x", y = "- log10 (pvalue)", hue='group', hue_order = ('down','normal','up'), palette= ("# 377EB8", "grey", "# E41A1C"), alpha=0.5, slots 15 Data=result)
Step5: setting scatter chart
# determine the display range of the axis xmin=-6xmax=10ymin=7ymax=13ax.spines ['right'] .set_visible (False) # remove the right border ax.spines [' top'] .set_visible (False) # remove the upper border ax.vlines (- cut_off_logFC, ymin, ymax, color='dimgrey',linestyle='dashed', linewidth=1) # draw vertical lines ax.vlines (cut_off_logFC, ymin, ymax, color='dimgrey',linestyle='dashed' Linewidth=1) # draw vertical line ax.hlines (- np.log10 (cut_off_pvalue), xmin, xmax, color='dimgrey',linestyle='dashed', linewidth=1) # draw vertical horizontal line ax.set_xticks (range (xmin, xmax, 4)) # set x-axis scale ax.set_yticks (range (ymin, ymax, 2)) # set y-axis scale ax.set_ylabel ('- log10 (pvalue)' Fontweight='bold') # set the y-axis label ax.set_xlabel ('log2 (fold change)', fontweight='bold') # set the x-axis label here The study on "how to draw with Python" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.