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 14 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 displayNumberSamplesInCohort2 = function () {
enemeth19 marked this conversation as resolved.
Show resolved Hide resolved
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);
};

displayNumberSamplesInCohort2()

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

// Setup Materialize Grid
addDivInside("violinGridRow", violinLoaderDiv.id);
var gridRow = document.getElementById("violinGridRow");
gridRow.classList.add("row");
Expand Down
53 changes: 40 additions & 13 deletions main/js/fillSelectBoxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
* @returns {undefined}
*/
const fillCancerTypeSelectBox = async function () {
const cancerTypesQuery = await firebrowse.fetchCohorts();
const cancerTypesQuery_1 = await firebrowse.fetchCohorts();
enemeth19 marked this conversation as resolved.
Show resolved Hide resolved
const cancerTypesQuery = cancerTypesQuery_1.reduce((acc, item) => item.cohort !== 'FPPP' ? [...acc, item] : acc, []);
cancerTypesQuery.sort();
let selectBox = document.getElementById("cancerTypeMultipleSelection");
for (let i = 0; i < cancerTypesQuery.length; i++) {
Expand Down Expand Up @@ -298,7 +299,11 @@ 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 +335,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))
let continuousFeaturesArr = [
"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
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems to be a constant which are normally placed in a constants.js file. Furthermore, constant names are capitalized and use snake case. In this case, this would let CONTINUOUS_FEATURES = []. No need to add "arr" as the features key word implies multiple items.

if(continuousFeaturesArr.includes(currentFeature))
temp.type = "continuous";
else
temp.type = "categorical";
Expand Down
Loading
Loading