Skip to content

Commit 25e9105

Browse files
committed
-> For sapien, add Bone Marrow to Blood, rename 'Blood and Bone Marrow'
1 parent c612ef8 commit 25e9105

File tree

4 files changed

+56
-9
lines changed

4 files changed

+56
-9
lines changed

etl/etl.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
from idc_collections.models import Program, Collection, Attribute, Attribute_Ranges, \
4444
Attribute_Display_Values, DataSource, DataSourceJoin, DataVersion, DataSetType, \
45-
Attribute_Set_Type, Attribute_Display_Category, ImagingDataCommonsVersion, Attribute_Tooltips
45+
Attribute_Set_Type, Attribute_Display_Category, ImagingDataCommonsVersion, Attribute_Tooltips, Citation
4646
from google_helpers.bigquery.bq_support import BigQuerySupport
4747

4848
from django.contrib.auth.models import User
@@ -319,6 +319,35 @@ def add_source_joins(froms, from_col, tos=None, to_col=None):
319319
DataSourceJoin.objects.bulk_create(src_joins)
320320

321321

322+
def load_citations(filename):
323+
try:
324+
cites_file = open(filename,"r")
325+
current_cites = [x.doi for x in Citation.objects.all()]
326+
new_cites = []
327+
updated_cites = {}
328+
for line in csv_reader(cites_file):
329+
if "doi, citation" in line:
330+
print("[STATUS] Saw header line during citation load - skipping!")
331+
continue
332+
if line[0] in current_cites:
333+
updated_cites[line[0]] = line[1]
334+
else:
335+
new_cites.append(Citation(doi=line[0], cite=line[1]))
336+
if len(new_cites):
337+
Citation.objects.bulk_create(new_cites)
338+
print("[STATUS] The following {} DOI citations were added: {}".format(len(new_cites), " ".join([x.doi for x in new_cites])))
339+
if len(updated_cites):
340+
to_update = Citation.objects.filter(doi__in=updated_cites.keys())
341+
for upd in to_update:
342+
upd.cite = updated_cites[upd.doi]
343+
Citation.objects.bulk_update(to_update, ["cite"])
344+
print("[STATUS] {} DOI citations were updated.".format(len(updated_cites)))
345+
except Exception as e:
346+
ERRORS_SEEN.append("Error seen while loading citations, check the logs!")
347+
logger.error("[ERROR] While trying to load citations: ")
348+
logger.exception(e)
349+
350+
322351
def load_collections(filename, data_version="8.0"):
323352
try:
324353
collection_file = open(filename, "r")
@@ -781,7 +810,8 @@ def parse_args():
781810

782811
parser = ArgumentParser()
783812
parser.add_argument('-j', '--config-file', type=str, default='', help='JSON file of version data to update')
784-
parser.add_argument('-c', '--collex-file', type=str, default='', help='CSV data of collections to update/create')
813+
parser.add_argument('-c', '--collex-file', type=str, default='', help='CSV data of citations to update/create')
814+
parser.add_argument('-i', '--cites-file', type=str, default='', help='CSV data of collections to update/create')
785815
parser.add_argument('-d', '--display-vals', type=str, default='', help='CSV data of display values to add/update')
786816
parser.add_argument('-p', '--programs-file', type=str, default='', help='CSV data of programs to add/update')
787817
parser.add_argument('-a', '--attributes-file', type=str, default='', help='CSV data of attributes to add/update')
@@ -821,6 +851,8 @@ def main():
821851
len(args.programs_file) and load_programs(args.programs_file)
822852
# Add/update collections - any new programs must be added first
823853
len(args.collex_file) and load_collections(args.collex_file)
854+
# Add/update any citations
855+
len(args.cites_file) and load_citations(args.cites_file)
824856
# Add/update display values for attributes
825857
if len(args.display_vals):
826858
dvals = load_display_vals(args.display_vals)

idc/views.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ def landing_page(request):
7676
"Testicles": "Testis",
7777
"Adrenal Glands": "Adrenal Gland",
7878
"Adrenal": "Adrenal Gland",
79-
"Lymph Node": "Lymph Nodes"
79+
"Lymph Node": "Lymph Nodes",
80+
"Bone Marrow": "Blood"
8081
}
8182

8283
skip = [

static/js/sapien.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,17 @@ require([
7373
Chest: 'rgb(0, 233, 255)',
7474
};
7575

76+
// Map the sapiens.js expected location names (typically uses a dash) to the TumorLocation
77+
// value stored in DICOM (freeform text to an extent, not normalized)
78+
//format: { <sapiens.js name>: [<TumorLocation>, ...], ...}
7679
var variantNames = {
7780
'Colorectal': ['Colon','Rectum'],
78-
"Blood": ["Marrow, Blood", "Marrow and Blood", "Blood"],
81+
"Blood": ["Marrow, Blood", "Marrow and Blood", "Blood", "Bone Marrow"],
7982
"Bile-Duct": ["Bile Duct"],
8083
"Adrenal-Gland": ["Adrenal Glands", "Adrenal"],
8184
"Testis": ["Testicles"],
8285
"Head-and-Neck": ["Head", "Head-Neck"],
83-
"Lymph-Nodes": ["Lymph Node", "Lymph Nodes"]
86+
"Lymph-Nodes": ["Lymph Node", "Lymph Nodes"],
8487
};
8588

8689
let data = case_counts.sort(function(a,b){
@@ -119,7 +122,7 @@ require([
119122

120123
root.prepend(rawsvg.buildHumanBody(null,null,' '));
121124

122-
let initChartWidth = 400;
125+
let initChartWidth = 500;
123126
let initChartHeight = 470;
124127
let top = 75;
125128
let labelSize ='12px';
@@ -130,7 +133,7 @@ require([
130133
let fileCountKey = 'fileCount';
131134

132135
const plotHeight = initChartHeight - 30;
133-
const barStartOffset = 130;
136+
const barStartOffset = 200;
134137
const barWidth = initChartWidth - barStartOffset;
135138
const maxCases = Math.max(...data.map(d => d[caseCountKey]));
136139
const halfPixel = 0.5;
@@ -188,7 +191,7 @@ require([
188191
.attr('fill', 'rgb(10, 10, 10)')
189192
.attr('font-size', labelSize)
190193
.style('text-anchor', 'end')
191-
.text(d => d[primarySiteKey])
194+
.text(d => d[primarySiteKey] === "Blood" ? "Blood and Bone Marrow" : d[primarySiteKey])
192195
.on('mouseover', function (d, i) { // needs `this`
193196
const organSelector = toClassName(d[primarySiteKey]);
194197
const organ = document.getElementById(organSelector);

static/js/sapien/raw-svg.js

Lines changed: 12 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)