Skip to content
Snippets Groups Projects
Commit 81b7860f authored by Olivier Langella's avatar Olivier Langella
Browse files

compute mass precision

parent 7dabcd4a
No related branches found
No related tags found
No related merge requests found
......@@ -142,7 +142,13 @@ std::size_t IdentificationGroup::countSubGroup()const {
return _group_store.countSubGroup();
}
void IdentificationGroup::collectMhDelta(std::vector< pappso::pappso_double> & delta_list, pappso::PrecisionUnit unit, ValidationState state) const {
for (auto & p_protein_match : _protein_match_list) {
if (p_protein_match->getValidationState() >= state) {
p_protein_match->collectMhDelta(delta_list, unit, state);
}
}
}
void IdentificationGroup::startGrouping (const GroupingType & grouping_type) {
qDebug() << "IdentificationGroup::startGrouping begin ";
if (_p_grp_experiment != nullptr) {
......
......@@ -84,6 +84,8 @@ public:
const QString getTabName() const;
bool contains (const MsRun * p_msrun) const;
void collectMhDelta(std::vector< pappso::pappso_double> & delta_list, pappso::PrecisionUnit unit, ValidationState state) const;
private :
GroupingExperiment * _p_grp_experiment= nullptr;
......
......@@ -50,7 +50,7 @@ ValidationState ProteinMatch::getValidationState() const {
return ValidationState::validAndChecked;
} else if (isValid()) {
return ValidationState::valid;
}
}
return ValidationState::notValid;
}
bool ProteinMatch::contains(PeptideMatch * peptide_match) const {
......@@ -390,3 +390,19 @@ void ProteinMatch::setGroupInstance(GroupStore & group_store) {
}
}
}
void ProteinMatch::collectMhDelta(std::vector< pappso::pappso_double> & delta_list, pappso::PrecisionUnit unit, ValidationState state) const {
for (auto & p_peptide_match : _peptide_match_list) {
if (p_peptide_match->getValidationState() >= state) {
pappso::pappso_double diff = p_peptide_match->getDeltaMass();
if (unit == pappso::PrecisionUnit::ppm) {
while (diff < -0.5) {
diff = diff + pappso::DIFFC12C13;
}
diff = (diff / p_peptide_match->getPeptideXtpSp().get()->getMz(1)) * pappso::ONEMILLION;
}
delta_list.push_back(diff);
}
}
}
......@@ -93,6 +93,8 @@ public:
/** @brief tells if this protein match contains this peptides
*/
bool contains(PeptideMatch * peptide_match) const;
void collectMhDelta(std::vector< pappso::pappso_double> & delta_list, pappso::PrecisionUnit unit, ValidationState state) const;
protected :
void setGroupingExperiment(GroupingExperiment * p_grp_experiment);
......
......@@ -177,7 +177,95 @@
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QFormLayout" name="formLayout_3"/>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<layout class="QFormLayout" name="formLayout_3"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>mean</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>median</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>standard deviation</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="precision_unit_combobox">
<item>
<property name="text">
<string>ppm</string>
</property>
</item>
<item>
<property name="text">
<string>dalton</string>
</property>
</item>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="mass_precision_mean_label">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="mass_precision_median_label">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="mass_precision_sd_label">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_3">
<property name="text">
<string>compute</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
......
......@@ -32,6 +32,7 @@
#include <QGridLayout>
#include <QMessageBox>
#include <pappsomspp/pappsoexception.h>
#include <numeric>
......@@ -141,24 +142,49 @@ void ProjectWindow::refreshGroup(IdentificationGroup * p_ident_group) {
void ProjectWindow::computeFdr(ValidationState state) {
pappso::pappso_double total_prot=0;
pappso::pappso_double false_prot=0;
for (IdentificationGroup * identification_group : _project_sp.get()->getIdentificationGroupList()) {
total_prot += identification_group->countProteinMatch(state);
false_prot += identification_group->countDecoyProteinMatch(state);
}
ui->protein_fdr_label->setText(QString("%1 %").arg(false_prot/total_prot));
pappso::pappso_double total_peptide=0;
pappso::pappso_double false_peptide=0;
for (IdentificationGroup * identification_group : _project_sp.get()->getIdentificationGroupList()) {
total_prot += identification_group->countProteinMatch(state);
false_prot += identification_group->countDecoyProteinMatch(state);
total_peptide += identification_group->countPeptideMatch(state);
false_peptide += identification_group->countDecoyPeptideMatch(state);
}
qDebug() << "ProjectWindow::computeFdr false_peptide=" <<false_peptide;
qDebug() << "ProjectWindow::computeFdr total_peptide=" <<total_peptide;
ui->protein_fdr_label->setText(QString("%1 %").arg(false_prot/total_prot));
ui->peptide_fdr_label->setText(QString("%1 %").arg(false_peptide/total_peptide));
}
void ProjectWindow::computeMassPrecision(ValidationState state) {
std::vector< pappso::pappso_double> delta_list;
pappso::PrecisionUnit unit = pappso::PrecisionUnit::dalton;
if (ui->precision_unit_combobox->currentText() == "ppm") {
unit = pappso::PrecisionUnit::ppm;
}
for (IdentificationGroup * identification_group : _project_sp.get()->getIdentificationGroupList()) {
identification_group->collectMhDelta(delta_list, unit, state);
}
pappso::pappso_double sum = std::accumulate(delta_list.begin(), delta_list.end(), 0);
pappso::pappso_double mean = sum / ((pappso::pappso_double) delta_list.size());
std::sort(delta_list.begin(), delta_list.end());
pappso::pappso_double median = delta_list[(delta_list.size()/2)];
pappso::pappso_double sd = 0;
for (pappso::pappso_double val : delta_list) {
sd = sd + ((val - mean) * (val - mean));
}
sd = sd / delta_list.size();
sd = std::sqrt(sd);
ui->mass_precision_mean_label->setText(QString::number(mean,'f',10));
ui->mass_precision_median_label->setText(QString::number(median,'f',10));
ui->mass_precision_sd_label->setText(QString::number(sd,'f',10));
}
void ProjectWindow::doFdrChanged() {
qDebug() << "ProjectWindow::doFdrChanged begin ";
_project_sp.get()->getProteinStore().setRegexpDecoyPattern(ui->decoy_protein_regexp_line_edit->text());
......@@ -348,5 +374,7 @@ void ProjectWindow::setProjectSp(ProjectSp project_sp) {
ui->decoy_protein_regexp_line_edit->setText(_project_sp.get()->getProteinStore().getRegexpDecoy().pattern());
computeFdr(ValidationState::grouped);
computeMassPrecision(ValidationState::validAndChecked);
this->setEnabled(true);
}
......@@ -69,6 +69,7 @@ protected :
void doViewProteinDetail(ProteinMatch * protein_match);
void doIdentificationGroupEdited(IdentificationGroup * p_identification_group);
void computeFdr(ValidationState state);
void computeMassPrecision(ValidationState state);
private :
void connectNewProteinListWindow();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment