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

Mostly UI updates #495

Merged
merged 15 commits into from
Oct 29, 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
35 changes: 34 additions & 1 deletion main/js/afterSubmit.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,40 @@ const buildViolinPlot = function(geneQuery, expressionData) {
var violinLoaderDiv = document.getElementById("violinLoaderDiv");
violinLoaderDiv.classList.remove("loader");

//Setup Materialize Grid
///////////////////////////////////
enemeth19 marked this conversation as resolved.
Show resolved Hide resolved
// DISPLAY NUMBER OF SAMPLES IN COHORT
///////////////////////////////////

var meme = document.getElementById("violinLoaderDiv");

var numCohortBarcodes2 = document.createElement("div");
numCohortBarcodes2.id = "numCohortBarcodes2";
numCohortBarcodes2.className = "row";

meme.appendChild(numCohortBarcodes2);

let displayNumberSamplesInCohort = function () {
let existingPara = document.getElementById("numSamplesInCohortText2");
if (existingPara) {
existingPara.remove();
}
// build label:
let para = document.createElement("p");
// Style the paragraph
para.style.textAlign = 'center';
para.style.color = '#4db6ac';
para.style.fontFamily = 'Georgia, "Times New Roman", Times, serif';
para.id = "numSamplesInCohortText2";

para.innerText = "Number of samples in cohort: " + (d3.map(expressionData, d => d.tcga_participant_barcode).keys()).length;
numCohortBarcodes2.appendChild(para);
};

displayNumberSamplesInCohort()

///////////////////////////////////

// Setup Materialize Grid
addDivInside("violinGridRow", violinLoaderDiv.id);
var gridRow = document.getElementById("violinGridRow");
gridRow.classList.add("row");
Expand Down
74 changes: 50 additions & 24 deletions main/js/fillSelectBoxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@
*/
const fillCancerTypeSelectBox = async function () {
const cancerTypesQuery = await firebrowse.fetchCohorts();
cancerTypesQuery.sort();
const cancerTypesQueryNoFPPP = cancerTypesQuery.reduce((acc, item) => item.cohort !== 'FPPP' ? [...acc, item] : acc, []);
cancerTypesQueryNoFPPP.sort();
let selectBox = document.getElementById("cancerTypeMultipleSelection");
for (let i = 0; i < cancerTypesQuery.length; i++) {
for (let i = 0; i < cancerTypesQueryNoFPPP.length; i++) {
let currentOption = document.createElement("option");
currentOption.value = cancerTypesQuery[i]["cohort"];
currentOption.value = cancerTypesQueryNoFPPP[i]["cohort"];
currentOption.text =
"(" +
cancerTypesQuery[i]["cohort"] +
cancerTypesQueryNoFPPP[i]["cohort"] +
") " +
cancerTypesQuery[i]["description"];
currentOption.id = cancerTypesQuery[i]["cohort"];
cancerTypesQueryNoFPPP[i]["description"];
currentOption.id = cancerTypesQueryNoFPPP[i]["cohort"];
selectBox.appendChild(currentOption);
}
let cancerTypeSelectedOptions = localStorage
Expand Down Expand Up @@ -88,29 +89,29 @@ let displayNumberSamples = async function () {
};
orderedCountQuery = orderThings(formatted_numbersOfSamples, myCohort, 'cohort')
// build label:
let string = "";
let numSamplesLabel = "";
let para;
for (let i = 0; i < orderedCountQuery.length; i++) {
if (string == "") {
string += orderedCountQuery[i].cohort + ": " + orderedCountQuery[i].mrnaseq;
if (numSamplesLabel == "") {
numSamplesLabel += orderedCountQuery[i].cohort + ": " + orderedCountQuery[i].mrnaseq;
para = document.createElement("P");
para.setAttribute(
"style",
'text-align: center; color: #4db6ac; font-family: Georgia, "Times New Roman", Times, serif'
);
para.setAttribute("id", "numSamplesText");
para.innerText = "Number of samples: " + string;
para.innerText = "Number of samples: " + numSamplesLabel;
cancerQuerySelectBox.appendChild(para);
} else {
document.getElementById("numSamplesText").remove();
string += ", " + orderedCountQuery[i].cohort +
numSamplesLabel += ", " + orderedCountQuery[i].cohort +
": " + orderedCountQuery[i].mrnaseq;
para.setAttribute(
"style",
'text-align: center; color: #4db6ac; font-family: Georgia, "Times New Roman", Times, serif'
);
para.setAttribute("id", "numSamplesText");
para.innerText = "Number of samples: " + string;
para.innerText = "Number of samples: " + numSamplesLabel;
cancerQuerySelectBox.appendChild(para);
}
}
Expand Down Expand Up @@ -298,7 +299,10 @@ let fillClinicalSelectBox = async function () {
}
}
}


const unwantedKeys = new Set(['date', 'tcga_participant_barcode', 'tool']);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems this set variable is declared in multiple places. It would be good practice to have a shared file instead of re-declaring the variable in each file every time.

clinicalKeys[0] = clinicalKeys[0].filter(item => !unwantedKeys.has(item));

let intersectedFeatures;
if(clinicalKeys.length > 1)
for(let i = 0; i < clinicalKeys.length - 1; i++) {
Expand Down Expand Up @@ -330,17 +334,39 @@ let fillClinicalSelectBox = async function () {
let temp = {name: currentFeature, type: "", isSelected: false};

let checkIfClinicalFeatureArrayIsNumeric = async function() {
var numbers = /^[0-9/.]+$/;
var continuousMap = allClinicalData.map(x => {
try {
x[currentFeature].match(numbers)
} catch(error) {} // Ignore error
});
var nullCount = continuousMap.filter(x => x == null).length;
var totalCount = continuousMap.length;
var percentContinuous = nullCount / totalCount;
let continuousFeaturesArr = ["days_to_death", "cervix_suv_results", "days_to_last_followup", "date_of_initial_pathologic_diagnosis", "number_of_lymph_nodes", "years_to_birth", "karnofsky_performance_score"]; // Array of features that should be considered continuous
if((percentContinuous < 0.75 && (currentFeature != 'vital_status')) || continuousFeaturesArr.includes(currentFeature))
const CONTINUOUS_FEATURES = [
"age_began_smoking_in_years",
"age_at_diagnosis",
"cervix_suv_results",
"date_of_initial_pathologic_diagnosis",
"days_to_death",
"days_to_last_followup",
"days_to_last_known_alive",
"days_to_psa",
"days_to_submitted_specimen_dx",
"gleason_score",
"height_cm_at_diagnosis",
"initial_pathologic_dx_year",
"karnofsky_performance_score",
"lymph_nodes_examined",
"lymph_nodes_examined_he_count",
"number_of_lymph_nodes",
"number_pack_years_smoked",
"pregnancies_count_ectopic",
"pregnancies_count_live_birth",
"pregnancies_count_stillbirth",
"pregnancies_count_total",
"pregnancy_spontaneous_abortion_count",
"pregnancy_therapeutic_abortion_count",
"psa_value",
"tobacco_smoking_history",
"tobacco_smoking_pack_years_smoked",
"tobacco_smoking_year_stopped",
"weight_kg_at_diagnosis",
"years_to_birth",
"year_of_tobacco_smoking_onset"
]; // Array of features that should be considered continuous
if(CONTINUOUS_FEATURES.includes(currentFeature))
temp.type = "continuous";
else
temp.type = "categorical";
Expand Down
Loading
Loading