Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions Kristian_rewrite_for_streamlit.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def common_type_gen(fragments_dataframe):
common_type = common_type.replace("n", "not annotated", regex=True)
common_type = common_type.replace("t-","",regex=True)
common_type = common_type.replace("-t","",regex=True)
#counts = common_type.value_counts()
fragments_dataframe['frag_types'] = common_type
return common_type

Expand All @@ -34,20 +33,18 @@ def common_type_gen(fragments_dataframe):
def common_type_hist(common_type):
fig = go.Figure([go.Histogram(x=common_type)])
return fig
#fig.show()


def common_type_pie(common_type):
counts = common_type.value_counts()
fig = go.Figure([go.Pie(labels=counts.keys(), values=counts)])
return fig
#fig.show()

# intensity distribution of different ions
# density or probability
def log_ion_intens_dist(fragments_dataframe):
histnorm = "probability"
types = fragments_dataframe["frag_types"].unique()
#print(types)
histograms = list()
for t in types:
histograms.append(go.Histogram(x=np.log(fragments_dataframe[fragments_dataframe.frag_types == t].frag_intensity),histnorm=histnorm, name=t, nbinsx=50))
Expand Down Expand Up @@ -79,7 +76,6 @@ def log_ion_intens_ridge(fragments_dataframe):
def rel_ion_intens_perc(fragments_dataframe):
histnorm = "probability"
types = fragments_dataframe["frag_types"].unique()
#print(types)
histograms = list()
for t in types:
histograms.append(go.Histogram(x=fragments_dataframe[fragments_dataframe.frag_types == t].perc_of_total_intensity,histnorm=histnorm, name=t, nbinsx=50))
Expand All @@ -89,7 +85,6 @@ def rel_ion_intens_perc(fragments_dataframe):
title="Histograms of relative intensities per ion type",
xaxis_title="intensity",
yaxis_title=histnorm)
#fig.show()
return fig

### Ridgelines of relative intensities per ion type
Expand All @@ -107,12 +102,12 @@ def rel_ion_intens_ridge(fragments_dataframe):
yaxis_title=histnorm)
return fig

#new comment
# relative intensity to total intensity distribution of different ions
# density or probability
def rel_ion_intens_prop(fragments_dataframe):
histnorm = "probability"
types = fragments_dataframe["frag_types"].unique()
#print(types)
histograms = list()
for t in types:
histograms.append(go.Histogram(x=fragments_dataframe[fragments_dataframe.frag_types == t].prop_intensity_to_base_peak,histnorm=histnorm, name=t, nbinsx=50))
Expand All @@ -122,7 +117,6 @@ def rel_ion_intens_prop(fragments_dataframe):
title="Histograms of relative intensities to base peak per ion type",
xaxis_title="Percentage per base peak",
yaxis_title=histnorm)
#fig.show()
return fig

## Ridgelines of relative intensities to base peak per ion type
Expand All @@ -145,7 +139,6 @@ def rel_ion_intens_prop_ridge(fragments_dataframe):
def mz_dist_ion_type(fragments_dataframe):
histnorm = "probability"
types = fragments_dataframe["frag_types"].unique()
#print(types)
histograms = list()
for t in types:
histograms.append(go.Histogram(x=fragments_dataframe[fragments_dataframe.frag_types == t].frag_mz, histnorm=histnorm, name=t, nbinsx=50))
Expand All @@ -155,7 +148,6 @@ def mz_dist_ion_type(fragments_dataframe):
title="Histograms of mz values per ion type",
xaxis_title="mz",
yaxis_title=histnorm)
#fig.show()
return fig


Expand All @@ -174,7 +166,6 @@ def per_spec_ion_type(spectra_dataframe):
title="Histograms of percentages of ion type per spectrum",
xaxis_title="Percentage",
yaxis_title=histnorm)
#fig.show()
return fig

### Same for intensities
Expand All @@ -190,7 +181,6 @@ def per_spec_ion_intens(spectra_dataframe):
title="Histograms of percentages of ion type per spectrum",
xaxis_title="Percentage",
yaxis_title=histnorm)
#fig.show()
return fig

## Distribution of total intensity of single amino acids
Expand Down