Skip to content

Commit

Permalink
figure S2
Browse files Browse the repository at this point in the history
  • Loading branch information
armaan-abraham committed Feb 2, 2024
1 parent e801ce5 commit c63e95a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
6 changes: 4 additions & 2 deletions ddmc/figures/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,12 @@ def genFigure():
def plot_motifs(pssm, ax: axes.Axes, titles=False, yaxis=False):
"""Generate logo plots of a list of PSSMs"""
pssm = pssm.T
pssm = pd.DataFrame(pssm)
if pssm.shape[0] == 11:
pssm.index = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]
elif pssm.shape[0] == 9:
pssm.index = [-5, -4, -3, -2, -1, 1, 2, 3, 4]
pssm.columns = AAlist
logo = lm.Logo(
pssm,
font_name="Arial",
Expand Down Expand Up @@ -202,7 +204,7 @@ def plot_cluster_kinase_distances(


def get_pvals_across_clusters(
label: pd.Series[bool] | np.ndarray[bool], centers: pd.DataFrame | np.ndarray
label: pd.Series | np.ndarray[bool], centers: pd.DataFrame | np.ndarray
) -> np.ndarray[float]:
pvals = []
centers_pos = centers[label]
Expand All @@ -213,7 +215,7 @@ def get_pvals_across_clusters(


def plot_p_signal_across_clusters_and_binary_feature(
label: pd.Series[bool] | np.ndarray[bool],
label: pd.Series | np.ndarray[bool],
centers: pd.DataFrame | np.ndarray,
label_name: str,
ax,
Expand Down
36 changes: 18 additions & 18 deletions ddmc/figures/figureMS2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@
"""

import numpy as np
from .common import getSetup, getDDMC_CPTAC
from .common import plot_motifs

from ddmc.clustering import DDMC
from ddmc.datasets import CPTAC, select_peptide_subset
from ddmc.figures.common import getSetup, plot_motifs

def makeFigure():
"""Get a list of the axis objects and create a figure"""
# Get list of axis objects
ax, f = getSetup((9, 9), (5, 5))

# Fit DDMC
model, _ = getDDMC_CPTAC(n_components=30, SeqWeight=100.0)
def makeFigure():
# Increase number of peptides and components for actual figure
p_signal = select_peptide_subset(CPTAC().get_p_signal(), keep_num=500)
model = DDMC(n_components=5, seq_weight=100).fit(p_signal)

pssms, cl_num = model.get_pssms(PsP_background=False)
ax, f = getSetup((9, 9), (5, 5))
clusters, pssms = model.get_pssms(PsP_background=False)
ylabels = np.arange(0, 21, 5)
xlabels = [20, 21, 22, 23, 24, 25]
for ii, cc in enumerate(cl_num):
cluster = "Cluster " + str(cc)
plot_motifs(pssms[ii], ax=ax[ii], titles=cluster, yaxis=[0, 10])
if ii not in ylabels:
ax[ii].set_ylabel("")
ax[ii].get_yaxis().set_visible(False)
if ii not in xlabels:
ax[ii].set_xlabel("")
ax[ii].get_xaxis().set_visible(False)
for cluster in clusters:
cluster_label = "Cluster " + str(cluster)
plot_motifs(pssms[cluster], ax=ax[cluster], titles=cluster_label, yaxis=[0, 10])
if cluster not in ylabels:
ax[cluster].set_ylabel("")
ax[cluster].get_yaxis().set_visible(False)
if cluster not in xlabels:
ax[cluster].set_xlabel("")
ax[cluster].get_xaxis().set_visible(False)

return f

0 comments on commit c63e95a

Please sign in to comment.