Skip to content

Commit

Permalink
volcano plot updated
Browse files Browse the repository at this point in the history
  • Loading branch information
reneshbedre committed Jan 29, 2021
1 parent 067b73d commit 10c8d2d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ python setup.py install

### Volcano plot

latest update v0.8.8
latest update v1.0.6

`bioinfokit.visuz.gene_exp.volcano(df, lfc, pv, lfc_thr, pv_thr, color, valpha, geneid, genenames, gfont, dim, r, ar,
dotsize, markerdot, sign_line, gstyle, show, figtype, axtickfontsize, axtickfontname, axlabelfontsize,
Expand All @@ -88,8 +88,8 @@ Parameters | Description
`df` |Pandas dataframe table having atleast gene IDs, log fold change, P-values or adjusted P-values columns
`lfc` | Name of a column having log or absolute fold change values [string][default:logFC]
`pv` | Name of a column having P-values or adjusted P-values [string][default:p_values]
`lfc_thr` | Log or absolute fold change cutoff for up and downregulated genes [float][default:1.0]
`pv_thr` | P-values or adjusted P-values cutoff for up and downregulated genes [float][default:0.05]
`lfc_thr` | Log fold change cutoff for up and downregulated genes [tuple or list][default:(1.0, 1.0)]
`pv_thr` | p value or adjusted p value cutoff for up and downregulated genes [tuple or list][default:(0.05, 0.05)]
`color` | Tuple of three colors [tuple or list][default: color=("green", "grey", "red")]
`valpha` | Transparency of points on volcano plot [float (between 0 and 1)][default: 1.0]
`geneid` | Name of a column having gene Ids. This is necessary for plotting gene label on the points [string][default: None]
Expand Down Expand Up @@ -126,7 +126,7 @@ Volcano plot image in same directory (volcano.png)

### Inverted Volcano plot

latest update v0.8.8
latest update v1.0.6

`bioinfokit.visuz.gene_exp.involcano(table, lfc, pv, lfc_thr, pv_thr, color, valpha, geneid, genenames, gfont, gstyle,
dotsize, markerdot, r, dim, show, figtype, axxlabel, axylabel, axlabelfontsize, axtickfontsize,
Expand All @@ -137,8 +137,8 @@ Parameters | Description
`table` |Pandas dataframe table having atleast gene IDs, log fold change, P-values or adjusted P-values
`lfc` | Name of a column having log fold change values [default:logFC]
`pv` | Name of a column having P-values or adjusted P-values [default:p_values]
`lfc_thr` | Log fold change cutoff for up and downregulated genes [default:1]
`pv_thr` | P-values or adjusted P-values cutoff for up and downregulated genes [default:0.05]
`lfc_thr` | Log fold change cutoff for up and downregulated genes [tuple or list] [default:(1.0, 1.0)]
`pv_thr` | p value or adjusted p value cutoff for up and downregulated genes [tuple or list] [default:(0.05, 0.05)]
`color` | Tuple of three colors [tuple or list][default: color=("green", "grey", "red")]
`valpha` | Transparency of points on volcano plot [float (between 0 and 1)][default: 1.0]
`geneid` | Name of a column having gene Ids. This is necessary for plotting gene label on the points [string][default: None]
Expand Down
4 changes: 4 additions & 0 deletions VERSIONLOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v1.0.6 has the following updates and changes (December 22, 2020)
- Individual log fold change and p value cutoff added for volcano and inverted volcano plot
(`bioinfokit.visuz.gene_exp.volcano` and `bioinfokit.visuz.gene_exp.involcano`)

v1.0.5 has the following updates and changes (December 22, 2020)
- `analys.gff.gff_to_gtf` function updated to handle dot value for phase in CDS features

Expand Down
2 changes: 1 addition & 1 deletion bioinfokit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name = "bioinfokit"
__version__ = "1.0.5"
__version__ = "1.0.6"
__author__ = "Renesh Bedre"


24 changes: 12 additions & 12 deletions bioinfokit/visuz.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ def __init__(self):
def geneplot(d, geneid, lfc, lfc_thr, pv_thr, genenames, gfont, pv, gstyle):
if genenames is not None and genenames == "deg":
for i in d[geneid].unique():
if (d.loc[d[geneid] == i, lfc].iloc[0] >= lfc_thr and d.loc[d[geneid] == i, pv].iloc[0] < pv_thr) or \
(d.loc[d[geneid] == i, lfc].iloc[0] <= -lfc_thr and d.loc[d[geneid] == i, pv].iloc[0] < pv_thr):
if (d.loc[d[geneid] == i, lfc].iloc[0] >= lfc_thr[0] and d.loc[d[geneid] == i, pv].iloc[0] < pv_thr[0]) or \
(d.loc[d[geneid] == i, lfc].iloc[0] <= -lfc_thr[1] and d.loc[d[geneid] == i, pv].iloc[0] < pv_thr[1]):
if gstyle==1:
plt.text(d.loc[d[geneid] == i, lfc].iloc[0], d.loc[d[geneid] == i, 'logpv_add_axy'].iloc[0], i,
fontsize=gfont)
Expand Down Expand Up @@ -127,8 +127,8 @@ def geneplot(d, geneid, lfc, lfc_thr, pv_thr, genenames, gfont, pv, gstyle):
print("Error: invalid gstyle choice")
sys.exit(1)

def volcano(df="dataframe", lfc=None, pv=None, lfc_thr=1, pv_thr=0.05, color=("green", "grey", "red"), valpha=1,
geneid=None, genenames=None, gfont=8, dim=(5, 5), r=300, ar=90, dotsize=8, markerdot="o",
def volcano(df="dataframe", lfc=None, pv=None, lfc_thr=(1, 1), pv_thr=(0.05, 0.05), color=("green", "grey", "red"),
valpha=1, geneid=None, genenames=None, gfont=8, dim=(5, 5), r=300, ar=90, dotsize=8, markerdot="o",
sign_line=False, gstyle=1, show=False, figtype='png', axtickfontsize=9,
axtickfontname="Arial", axlabelfontsize=9, axlabelfontname="Arial", axxlabel=None,
axylabel=None, xlm=None, ylm=None, plotlegend=False, legendpos='best',
Expand All @@ -144,8 +144,8 @@ def volcano(df="dataframe", lfc=None, pv=None, lfc_thr=1, pv_thr=0.05, color=("g
# it may update old instance of df
df = df.drop(['color_add_axy', 'logpv_add_axy'], axis=1, errors='ignore')
assert len(set(color)) == 3, 'unique color must be size of 3'
df.loc[(df[lfc] >= lfc_thr) & (df[pv] < pv_thr), 'color_add_axy'] = color[0] # upregulated
df.loc[(df[lfc] <= -lfc_thr) & (df[pv] < pv_thr), 'color_add_axy'] = color[2] # downregulated
df.loc[(df[lfc] >= lfc_thr[0]) & (df[pv] < pv_thr[0]), 'color_add_axy'] = color[0] # upregulated
df.loc[(df[lfc] <= -lfc_thr[1]) & (df[pv] < pv_thr[1]), 'color_add_axy'] = color[2] # downregulated
df['color_add_axy'].fillna(color[1], inplace=True) # intermediate
df['logpv_add_axy'] = -(np.log10(df[pv]))
# plot
Expand All @@ -164,9 +164,9 @@ def volcano(df="dataframe", lfc=None, pv=None, lfc_thr=1, pv_thr=0.05, color=("g
plt.scatter(df[lfc], df['logpv_add_axy'], c=color_result_num, cmap=ListedColormap(color), alpha=valpha,
s=dotsize, marker=markerdot)
if sign_line:
plt.axhline(y=-np.log10(pv_thr), linestyle='--', color='#7d7d7d', linewidth=1)
plt.axvline(x=lfc_thr, linestyle='--', color='#7d7d7d', linewidth=1)
plt.axvline(x=-lfc_thr, linestyle='--', color='#7d7d7d', linewidth=1)
plt.axhline(y=-np.log10(pv_thr[0]), linestyle='--', color='#7d7d7d', linewidth=1)
plt.axvline(x=lfc_thr[0], linestyle='--', color='#7d7d7d', linewidth=1)
plt.axvline(x=-lfc_thr[1], linestyle='--', color='#7d7d7d', linewidth=1)
gene_exp.geneplot(df, geneid, lfc, lfc_thr, pv_thr, genenames, gfont, pv, gstyle)

if axxlabel:
Expand All @@ -177,7 +177,7 @@ def volcano(df="dataframe", lfc=None, pv=None, lfc_thr=1, pv_thr=0.05, color=("g
general.axis_ticks(xlm, ylm, axtickfontsize, axtickfontname, ar)
general.get_figure(show, r, figtype, figname)

def involcano(df="dataframe", lfc="logFC", pv="p_values", lfc_thr=1, pv_thr=0.05, color=("green", "grey", "red"),
def involcano(df="dataframe", lfc="logFC", pv="p_values", lfc_thr=(1, 1), pv_thr=(0.05, 0.05), color=("green", "grey", "red"),
valpha=1, geneid=None, genenames=None, gfont=8, dim=(5, 5), r=300, ar=90, dotsize=8, markerdot="o",
sign_line=False, gstyle=1, show=False, figtype='png', axtickfontsize=9,
axtickfontname="Arial", axlabelfontsize=9, axlabelfontname="Arial", axxlabel=None,
Expand All @@ -192,8 +192,8 @@ def involcano(df="dataframe", lfc="logFC", pv="p_values", lfc_thr=1, pv_thr=0.05
# it may update old instance of df
df = df.drop(['color_add_axy', 'logpv_add_axy'], axis=1, errors='ignore')
assert len(set(color)) == 3, 'unique color must be size of 3'
df.loc[(df[lfc] >= lfc_thr) & (df[pv] < pv_thr), 'color_add_axy'] = color[0] # upregulated
df.loc[(df[lfc] <= -lfc_thr) & (df[pv] < pv_thr), 'color_add_axy'] = color[2] # downregulated
df.loc[(df[lfc] >= lfc_thr[0]) & (df[pv] < pv_thr[0]), 'color_add_axy'] = color[0] # upregulated
df.loc[(df[lfc] <= -lfc_thr[1]) & (df[pv] < pv_thr[1]), 'color_add_axy'] = color[2] # downregulated
df['color_add_axy'].fillna(color[1], inplace=True) # intermediate
df['logpv_add_axy'] = -(np.log10(df[pv]))

Expand Down

0 comments on commit 10c8d2d

Please sign in to comment.