Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added TsvDiff tool #610

Merged
merged 4 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions src/ExportcBioportal/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ class ConcreteTool
int idx_icd10_catalog = samples.columnIndex("icd10_catalog");
int idx_oncotree_code = samples.columnIndex("oncotree_code");

for (int i=0; i< samples.rowCount(); i++)
for (int i=0; i< samples.count(); i++)
{
QStringList row = samples.row(i);
const QStringList& row = samples[i];
QString sample_id = db.sampleId(row[idx_tumor_name], true);

SampleMTBmetadata mtb_data;
Expand Down Expand Up @@ -177,9 +177,9 @@ class ConcreteTool
int idx_datatype = getIndex(headers, "datatype");
int idx_prio = getIndex(headers, "priority");

for (int i=0; i<attr_data.rowCount(); i++)
for (int i=0; i<attr_data.count(); i++)
{
QStringList row = attr_data.row(i);
const QStringList& row = attr_data[i];

SampleAttribute attr;
attr.name = row[idx_attr_name];
Expand Down
6 changes: 3 additions & 3 deletions src/GSvar/CohortExpressionDataWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void CohortExpressionDataWidget::loadExpressionData()
}

//set dimensions
ui_->tw_cohort_data->setRowCount(cohort_expression_data.rowCount());
ui_->tw_cohort_data->setRowCount(cohort_expression_data.count());
ui_->tw_cohort_data->setColumnCount(cohort_expression_data.headers().size());

// create header
Expand All @@ -69,9 +69,9 @@ void CohortExpressionDataWidget::loadExpressionData()
}

//fill table
for(int row_idx=0; row_idx<cohort_expression_data.rowCount(); ++row_idx)
for(int row_idx=0; row_idx<cohort_expression_data.count(); ++row_idx)
{
QStringList row = cohort_expression_data.row(row_idx);
const QStringList& row = cohort_expression_data[row_idx];
for (int col_idx = 0; col_idx < tsv_header.size(); ++col_idx)
{
if(col_idx > 0)
Expand Down
4 changes: 2 additions & 2 deletions src/GSvar/DiseaseCourseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ void DiseaseCourseWidget::createTableView()
{
for (int col_idx = 0; col_idx < table_data_.cfdna_samples.length(); ++col_idx)
{
if(table_data_.mrd_tables.at(col_idx).rowCount() > 0)
if(table_data_.mrd_tables.at(col_idx).count() > 0)
{
ui_->mrd->setItem(row_idx, col_idx, GUIHelper::createTableItem(table_data_.mrd_tables.at(col_idx).row(0).at(row_idx), Qt::AlignRight));
ui_->mrd->setItem(row_idx, col_idx, GUIHelper::createTableItem(table_data_.mrd_tables.at(col_idx)[0].at(row_idx), Qt::AlignRight));
continue;
}
ui_->mrd->setItem(row_idx, col_idx, GUIHelper::createTableItem(""));
Expand Down
52 changes: 26 additions & 26 deletions src/GSvar/ExpressionExonWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void ExpressionExonWidget::loadExpressionFile()
qDebug() << "TSV parsed";

//init filter data
filter_result_ = FilterResult(expression_data_.rowCount());
filter_result_ = FilterResult(expression_data_.count());

QApplication::restoreOverrideCursor();
}
Expand Down Expand Up @@ -215,7 +215,7 @@ void ExpressionExonWidget::applyFilters()
ui_->tw_expression_table->setEnabled(false);

filter_result_.reset(true);
int filtered_lines = expression_data_.rowCount();
int filtered_lines = expression_data_.count();

QTime timer;
timer.start();
Expand All @@ -239,11 +239,11 @@ void ExpressionExonWidget::applyFilters()

if (gene_idx != -1)
{
for(int row_idx=0; row_idx<expression_data_.rowCount(); ++row_idx)
for(int row_idx=0; row_idx<expression_data_.count(); ++row_idx)
{
if (!filter_result_.flags()[row_idx]) continue;

filter_result_.flags()[row_idx] = variant_gene_set_.contains(expression_data_.row(row_idx).at(gene_idx).toUtf8().trimmed());
filter_result_.flags()[row_idx] = variant_gene_set_.contains(expression_data_[row_idx].at(gene_idx).toUtf8().trimmed());
}
}

Expand All @@ -265,12 +265,12 @@ void ExpressionExonWidget::applyFilters()
if (genes_joined.contains("*")) //with wildcards
{
QRegExp reg(genes_joined.replace("-", "\\-").replace("*", "[A-Z0-9-]*"));
for(int row_idx=0; row_idx<expression_data_.rowCount(); ++row_idx)
for(int row_idx=0; row_idx<expression_data_.count(); ++row_idx)
{
if (!filter_result_.flags()[row_idx]) continue;

// generate GeneSet from column text
GeneSet sv_genes = GeneSet::createFromText(expression_data_.row(row_idx).at(gene_idx).toUtf8(), ',');
GeneSet sv_genes = GeneSet::createFromText(expression_data_[row_idx].at(gene_idx).toUtf8(), ',');

bool match_found = false;
foreach(const QByteArray& sv_gene, sv_genes)
Expand All @@ -286,12 +286,12 @@ void ExpressionExonWidget::applyFilters()
}
else //without wildcards
{
for(int row_idx=0; row_idx<expression_data_.rowCount(); ++row_idx)
for(int row_idx=0; row_idx<expression_data_.count(); ++row_idx)
{
if (!filter_result_.flags()[row_idx]) continue;

// generate GeneSet from column text
GeneSet sv_genes = GeneSet::createFromText(expression_data_.row(row_idx).at(gene_idx).toUtf8(), ',');
GeneSet sv_genes = GeneSet::createFromText(expression_data_[row_idx].at(gene_idx).toUtf8(), ',');

filter_result_.flags()[row_idx] = sv_genes.intersectsWith(gene_whitelist);
}
Expand Down Expand Up @@ -321,12 +321,12 @@ void ExpressionExonWidget::applyFilters()
try
{
double min_rpb_value = ui_->sb_min_rpb->value();
for(int row_idx=0; row_idx<expression_data_.rowCount(); ++row_idx)
for(int row_idx=0; row_idx<expression_data_.count(); ++row_idx)
{
//skip already filtered
if (!filter_result_.flags()[row_idx]) continue;

QString value = expression_data_.row(row_idx).at(idx).toUtf8();
QString value = expression_data_[row_idx].at(idx).toUtf8();
if (value.isEmpty() || value == "n/a")
{
filter_result_.flags()[row_idx] = false;
Expand Down Expand Up @@ -364,12 +364,12 @@ void ExpressionExonWidget::applyFilters()
try
{
double min_srpb_value = ui_->sb_min_srpb_sample->value();
for(int row_idx=0; row_idx<expression_data_.rowCount(); ++row_idx)
for(int row_idx=0; row_idx<expression_data_.count(); ++row_idx)
{
//skip already filtered
if (!filter_result_.flags()[row_idx]) continue;

QString value = expression_data_.row(row_idx).at(idx).toUtf8();
QString value = expression_data_[row_idx].at(idx).toUtf8();
if (value.isEmpty() || value == "n/a")
{
filter_result_.flags()[row_idx] = false;
Expand Down Expand Up @@ -413,12 +413,12 @@ void ExpressionExonWidget::applyFilters()
}
else
{
for(int row_idx=0; row_idx<expression_data_.rowCount(); ++row_idx)
for(int row_idx=0; row_idx<expression_data_.count(); ++row_idx)
{
//skip already filtered
if (!filter_result_.flags()[row_idx]) continue;

QString biotype = expression_data_.row(row_idx).at(idx_biotype);
QString biotype = expression_data_[row_idx].at(idx_biotype);
filter_result_.flags()[row_idx] = selected_biotypes.contains(biotype.replace("_", " "));
}
}
Expand Down Expand Up @@ -454,13 +454,13 @@ void ExpressionExonWidget::applyFilters()
{
double min_expr_value = ui_->sb_low_expression->value();

for(int row_idx=0; row_idx<expression_data_.rowCount(); ++row_idx)
for(int row_idx=0; row_idx<expression_data_.count(); ++row_idx)
{
//skip already filtered
if (!filter_result_.flags()[row_idx]) continue;

QString value_sample = expression_data_.row(row_idx).at(idx_srpb).toUtf8();
QString value_mean_cohort = expression_data_.row(row_idx).at(idx_cohort_mean).toUtf8();
QString value_sample = expression_data_[row_idx].at(idx_srpb).toUtf8();
QString value_mean_cohort = expression_data_[row_idx].at(idx_cohort_mean).toUtf8();
if (value_sample.isEmpty() || value_sample == "n/a" || value_mean_cohort.isEmpty() || value_mean_cohort == "n/a")
{
filter_result_.flags()[row_idx] = false;
Expand Down Expand Up @@ -498,12 +498,12 @@ void ExpressionExonWidget::applyFilters()
try
{
double min_cohort_mean = ui_->sb_min_srpb_cohort->value();
for(int row_idx=0; row_idx<expression_data_.rowCount(); ++row_idx)
for(int row_idx=0; row_idx<expression_data_.count(); ++row_idx)
{
//skip already filtered
if (!filter_result_.flags()[row_idx]) continue;

QString value = expression_data_.row(row_idx).at(idx).toUtf8();
QString value = expression_data_[row_idx].at(idx).toUtf8();
if (value.isEmpty() || value == "n/a")
{
filter_result_.flags()[row_idx] = false;
Expand Down Expand Up @@ -541,12 +541,12 @@ void ExpressionExonWidget::applyFilters()
try
{
double min_logfc = ui_->sb_min_logfc->value();
for(int row_idx=0; row_idx<expression_data_.rowCount(); ++row_idx)
for(int row_idx=0; row_idx<expression_data_.count(); ++row_idx)
{
//skip already filtered
if (!filter_result_.flags()[row_idx]) continue;

QString value = expression_data_.row(row_idx).at(idx).toUtf8();
QString value = expression_data_[row_idx].at(idx).toUtf8();
if (value.isEmpty() || value == "n/a")
{
filter_result_.flags()[row_idx] = false;
Expand Down Expand Up @@ -584,12 +584,12 @@ void ExpressionExonWidget::applyFilters()
try
{
double min_zscore = ui_->sb_min_zscore->value();
for(int row_idx=0; row_idx<expression_data_.rowCount(); ++row_idx)
for(int row_idx=0; row_idx<expression_data_.count(); ++row_idx)
{
//skip already filtered
if (!filter_result_.flags()[row_idx]) continue;

QString value = expression_data_.row(row_idx).at(idx).toUtf8();
QString value = expression_data_[row_idx].at(idx).toUtf8();
if (value.isEmpty() || value == "n/a")
{
filter_result_.flags()[row_idx] = false;
Expand Down Expand Up @@ -780,12 +780,12 @@ void ExpressionExonWidget::updateTable()

// fill table
int table_row_idx = 0;
for(int file_line_idx=0; file_line_idx<expression_data_.rowCount(); ++file_line_idx)
for(int file_line_idx=0; file_line_idx<expression_data_.count(); ++file_line_idx)
{
if (!filter_result_.passing(file_line_idx)) continue;


QStringList row = expression_data_.row(file_line_idx);
const QStringList& row = expression_data_[file_line_idx];

//iterate over columns
for (int col_idx = 0; col_idx < column_names_.size(); ++col_idx)
Expand Down Expand Up @@ -834,7 +834,7 @@ void ExpressionExonWidget::updateTable()
ui_->tw_expression_table->sortByColumn(9, Qt::DescendingOrder);

//set number of filtered / total rows
ui_->l_filtered_rows->setText(QByteArray::number(filter_result_.flags().count(true)) + " / " + QByteArray::number(expression_data_.rowCount()));
ui_->l_filtered_rows->setText(QByteArray::number(filter_result_.flags().count(true)) + " / " + QByteArray::number(expression_data_.count()));

//optimize table view
GUIHelper::resizeTableCellWidths(ui_->tw_expression_table, 350);
Expand Down
28 changes: 14 additions & 14 deletions src/GSvar/ExpressionGeneWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void ExpressionGeneWidget::applyFilters(int max_rows)
if (filtering_in_progress_) return;
filtering_in_progress_ = true;
//skip if not necessary
int row_count = expression_data_.rowCount();
int row_count = expression_data_.count();
if (row_count == 0) return;

try
Expand Down Expand Up @@ -183,7 +183,7 @@ void ExpressionGeneWidget::applyFilters(int max_rows)
{
if (!filter_result_.flags()[row_idx]) continue;

filter_result_.flags()[row_idx] = variant_gene_set_.contains(expression_data_.row(row_idx).at(gene_idx).toUtf8().trimmed());
filter_result_.flags()[row_idx] = variant_gene_set_.contains(expression_data_[row_idx].at(gene_idx).toUtf8().trimmed());
}

qDebug() << filter_result_.countPassing();
Expand All @@ -204,7 +204,7 @@ void ExpressionGeneWidget::applyFilters(int max_rows)
if (!filter_result_.flags()[row_idx]) continue;

// generate GeneSet from column text
GeneSet sv_genes = GeneSet::createFromText(expression_data_.row(row_idx).at(gene_idx).toUtf8().trimmed(), ',');
GeneSet sv_genes = GeneSet::createFromText(expression_data_[row_idx].at(gene_idx).toUtf8().trimmed(), ',');

bool match_found = false;
foreach(const QByteArray& sv_gene, sv_genes)
Expand All @@ -225,7 +225,7 @@ void ExpressionGeneWidget::applyFilters(int max_rows)
if (!filter_result_.flags()[row_idx]) continue;

// generate GeneSet from column text
GeneSet sv_genes = GeneSet::createFromText(expression_data_.row(row_idx).at(gene_idx).toUtf8().trimmed(), ',');
GeneSet sv_genes = GeneSet::createFromText(expression_data_[row_idx].at(gene_idx).toUtf8().trimmed(), ',');

filter_result_.flags()[row_idx] = sv_genes.intersectsWith(gene_whitelist);
}
Expand All @@ -245,7 +245,7 @@ void ExpressionGeneWidget::applyFilters(int max_rows)
//skip already filtered
if (!filter_result_.flags()[row_idx]) continue;

QString value = expression_data_.row(row_idx).at(tpm_idx).trimmed();
QString value = expression_data_[row_idx].at(tpm_idx).trimmed();
if (value.isEmpty() || value == "n/a")
{
filter_result_.flags()[row_idx] = false;
Expand Down Expand Up @@ -281,7 +281,7 @@ void ExpressionGeneWidget::applyFilters(int max_rows)
//skip already filtered
if (!filter_result_.flags()[row_idx]) continue;

QString biotype = expression_data_.row(row_idx).at(idx_biotype).trimmed().replace("_", " ");
QString biotype = expression_data_[row_idx].at(idx_biotype).trimmed().replace("_", " ");
filter_result_.flags()[row_idx] = selected_biotypes.contains(biotype);
}

Expand All @@ -298,7 +298,7 @@ void ExpressionGeneWidget::applyFilters(int max_rows)
//skip already filtered
if (!filter_result_.flags()[row_idx]) continue;

QString value_sample = expression_data_.row(row_idx).at(tpm_idx);
QString value_sample = expression_data_[row_idx].at(tpm_idx);
if (value_sample.isEmpty() || value_sample == "n/a")
{
filter_result_.flags()[row_idx] = false;
Expand Down Expand Up @@ -340,7 +340,7 @@ void ExpressionGeneWidget::applyFilters(int max_rows)

//get gene and tpm value
bool in_db = false;
QByteArray ensg_number = expression_data_.row(row_idx).at(gene_id_idx).toUtf8().trimmed();
QByteArray ensg_number = expression_data_[row_idx].at(gene_id_idx).toUtf8().trimmed();
QByteArray gene_symbol;

if(ensg_mapping_.contains(ensg_number))
Expand All @@ -353,7 +353,7 @@ void ExpressionGeneWidget::applyFilters(int max_rows)
continue;
}
double tpm = 0.0;
QString value = expression_data_.row(row_idx).at(tpm_idx).toUtf8().trimmed();
QString value = expression_data_[row_idx].at(tpm_idx).toUtf8().trimmed();
if (!(value.isEmpty() || value == "n/a"))
{
tpm = Helper::toDouble(value);
Expand Down Expand Up @@ -777,7 +777,7 @@ void ExpressionGeneWidget::loadExpressionData()


//init filter mask
filter_result_ = FilterResult(expression_data_.rowCount());
filter_result_ = FilterResult(expression_data_.count());

QApplication::restoreOverrideCursor();
}
Expand Down Expand Up @@ -885,12 +885,12 @@ void ExpressionGeneWidget::updateTable(int max_rows)
}


for(int file_row_idx=0; file_row_idx<expression_data_.rowCount(); ++file_row_idx)
for(int file_row_idx=0; file_row_idx<expression_data_.count(); ++file_row_idx)
{
//skip rows which are filtered out
if(!filter_result_.flags()[file_row_idx]) continue;

QStringList row = expression_data_.row(file_row_idx);
const QStringList& row = expression_data_[file_row_idx];
QByteArray ensg_number = row.at(gene_id_idx).toUtf8();
QByteArray gene;
if (ensg_mapping_.contains(ensg_number)) gene = ensg_mapping_.value(ensg_number);
Expand Down Expand Up @@ -989,11 +989,11 @@ void ExpressionGeneWidget::updateTable(int max_rows)
//Set number of filtered / total rows
if (filter_result_.countPassing() >= max_rows)
{
ui_->filtered_rows->setText(QByteArray::number(max_rows) + "+ / " + QByteArray::number(expression_data_.rowCount()) + " (showing only first " + QByteArray::number(max_rows) + ")");
ui_->filtered_rows->setText(QByteArray::number(max_rows) + "+ / " + QByteArray::number(expression_data_.count()) + " (showing only first " + QByteArray::number(max_rows) + ")");
}
else
{
ui_->filtered_rows->setText(QByteArray::number(ui_->expression_data->rowCount()) + " / " + QByteArray::number(expression_data_.rowCount()));
ui_->filtered_rows->setText(QByteArray::number(ui_->expression_data->rowCount()) + " / " + QByteArray::number(expression_data_.count()));
}


Expand Down
6 changes: 3 additions & 3 deletions src/GSvar/FusionWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ void FusionWidget::loadFusionData()
}

//fill table widget with expression data
ui_->fusions->setRowCount(fusion_data.rowCount());
for(int row_idx=0; row_idx<fusion_data.rowCount(); ++row_idx)
ui_->fusions->setRowCount(fusion_data.count());
for(int row_idx=0; row_idx<fusion_data.count(); ++row_idx)
{
QStringList row = fusion_data.row(row_idx);
const QStringList& row = fusion_data[row_idx];
for (int col_idx = 0; col_idx < column_names_.size(); ++col_idx)
{
if(numeric_columns_.at(col_idx))
Expand Down
6 changes: 3 additions & 3 deletions src/GSvar/PRSWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ void PRSWidget::initGui()
}

//add contents
ui_.prs->setRowCount(prs_table_.rowCount());
for (int r=0; r<prs_table_.rowCount(); ++r)
ui_.prs->setRowCount(prs_table_.count());
for (int r=0; r<prs_table_.count(); ++r)
{
for (int c=0; c<headers.count(); ++c)
{
ui_.prs->setItem(r , c, GUIHelper::createTableItem(prs_table_.row(r)[c].trimmed()));
ui_.prs->setItem(r , c, GUIHelper::createTableItem(prs_table_[r][c].trimmed()));
}
}

Expand Down
Loading