Exponential value plotting in Python [closed]
I have a list of exponential value, and I would like to plot in Python the distribution. How can Ido it to be significant and with sense?
My value are like this list:
[0.0, 1.05e-84, 1.05e-84, 1.05e-84, 1.05e-84, 1.05e-84, 1.05e-84, 4.27e-35, 0.0, 3.18e-86, 3.18e-86, 3.18e-86, 3.61e-56, 1.92e-16, 7.3e-13, 7.3e-13, 7.3e-13, 9.04e-11, 9.04e-11, 2.3e-08, 4.3e-08, 4.3e-08, 0.000159, 0.000159, 0.0, 0.0, 0.18, 6.6, 3.0, 3.2, 4.6, 6.4, 7.7, 8.4, 8.8, 9.0, 8.92e-80, 7.8e-53, 7.8e-53, 1.33e-51, 2.56e-51, 2.56e-51, 2.56e-51, 2.56e-51, 2.6, 2.6, 2.6, 2.6, 2.6, 3.9, 3.9, 3.9, 3.9, 9.45e-166, 5.69e-44, 8.34e-44, 8.34e-44, 1.39e-43, 1.39e-43]
I need this plot to decide a threshold for another analysis. What I'm looking for it is like this (the data type is the same): https://www.researchgate.net/figure/E-value-distribution-of-contig-sequences-BLAST-results-in-the-sweetpotato-root_fig3_247770651
Also I would like to use gnuplot instead of Python if easier.
Thank you
Solution 1:
Is this what you are thinking?
import numpy as np
import matplotlib.pyplot as plt
data = np.array([0.0, 1.05e-84, 1.05e-84, 1.05e-84, 1.05e-84, 1.05e-84, 1.05e-84, 4.27e-35, 0.0, 3.18e-86, 3.18e-86, 3.18e-86, 3.61e-56, 1.92e-16, 7.3e-13, 7.3e-13, 7.3e-13, 9.04e-11, 9.04e-11, 2.3e-08, 4.3e-08, 4.3e-08, 0.000159, 0.000159, 0.0, 0.0, 0.18, 6.6, 3.0, 3.2, 4.6, 6.4, 7.7, 8.4, 8.8, 9.0, 8.92e-80, 7.8e-53, 7.8e-53, 1.33e-51, 2.56e-51, 2.56e-51, 2.56e-51, 2.56e-51, 2.6, 2.6, 2.6, 2.6, 2.6, 3.9, 3.9, 3.9, 3.9, 9.45e-166, 5.69e-44, 8.34e-44, 8.34e-44, 1.39e-43, 1.39e-43])
plt.plot(data)
plt.yscale('log')
plt.show()
Output:
FOLLOWUP
This does a histogram of the exponents of your values. Note that I have to change the zeros to ones to allow the log10 call.
import numpy as np
import matplotlib.pyplot as plt
data = np.array([0.0, 1.05e-84, 1.05e-84, 1.05e-84, 1.05e-84, 1.05e-84, 1.05e-84, 4.27e-35, 0.0, 3.18e-86, 3.18e-86, 3.18e-86, 3.61e-56, 1.92e-16, 7.3e-13, 7.3e-13, 7.3e-13, 9.04e-11, 9.04e-11, 2.3e-08, 4.3e-08, 4.3e-08, 0.000159, 0.000159, 0.0, 0.0, 0.18, 6.6, 3.0, 3.2, 4.6, 6.4, 7.7, 8.4, 8.8, 9.0, 8.92e-80, 7.8e-53, 7.8e-53, 1.33e-51, 2.56e-51, 2.56e-51, 2.56e-51, 2.56e-51, 2.6, 2.6, 2.6, 2.6, 2.6, 3.9, 3.9, 3.9, 3.9, 9.45e-166, 5.69e-44, 8.34e-44, 8.34e-44, 1.39e-43, 1.39e-43])
data += (data==0.0).astype(int)
data1 = -np.log10( data ).astype( int )
print(data1)
plt.hist(data1, 60)
plt.show()
Output: