1568d3c9a7cd5d15f6299f8fdabd3aa914802ad8 kate Wed Mar 16 16:08:40 2016 -0700 Integrate gene class into GTEx cgi support. refs #15645 diff --git src/hg/hgTracks/gtexTracks.c src/hg/hgTracks/gtexTracks.c index 4ddec4e..56c5e3a 100644 --- src/hg/hgTracks/gtexTracks.c +++ src/hg/hgTracks/gtexTracks.c @@ -21,31 +21,31 @@ double maxMedian; /* Maximum median rpkm for all tissues */ boolean isComparison; /* Comparison of two sample sets (e.g. male/female). */ boolean isDifference; /* True if comparison is shown as a single difference graph. False if displayed as two graphs, one oriented downward */ char *graphType; /* Additional info about graph (e.g. type of comparison graph */ struct rgbColor *colors; /* Color palette for tissues */ boolean doLogTransform; /* Log10(x+1) */ struct gtexTissue *tissues; /* Cache tissue names, descriptions */ struct hash *tissueFilter; /* For filter. NULL out excluded tissues */ }; struct gtexGeneInfo /* GTEx gene model, names, and expression medians */ { struct gtexGeneInfo *next; /* Next in singly linked list */ - struct gtexGeneBed *geneBed;/* Gene name, id, canonical transcript, exp count and medians + struct gtexGeneBed *geneBed;/* Gene name, id, type, exp count and medians from BED table */ struct genePred *geneModel; /* Gene structure from model table */ char *description; /* Gene description */ double *medians1; /* Computed medians */ double *medians2; /* Computed medians for comparison (inverse) graph */ int height; /* Item height in pixels */ }; #define MAX_DESC 200 /***********************************************/ /* Color gene models using GENCODE conventions */ static struct rgbColor codingColor = {12, 12, 120}; // #0C0C78 static struct rgbColor nonCodingColor = {0, 100, 0}; // #006400 @@ -65,64 +65,43 @@ static void initGeneColors(struct hvGfx *hvg) /* Get and cache indexes for color values */ { if (statusColors.coding != 0) return; statusColors.coding = hvGfxFindColorIx(hvg, codingColor.r, codingColor.g, codingColor.b); statusColors.nonCoding = hvGfxFindColorIx(hvg, nonCodingColor.r, nonCodingColor.g, nonCodingColor.b); statusColors.pseudo = hvGfxFindColorIx(hvg, pseudoColor.r, pseudoColor.g, pseudoColor.b); statusColors.problem = hvGfxFindColorIx(hvg, problemColor.r, problemColor.g, problemColor.b); statusColors.unknown = hvGfxFindColorIx(hvg, unknownColor.r, unknownColor.g, unknownColor.b); } static Color getGeneClassColor(struct hvGfx *hvg, struct gtexGeneBed *geneBed) -/* Find GENCODE color for gene type. - * NOTE: this is based on defined gene biotypes from GENCODE V19, mapped to the classes - * defined for transcripts, as follows: - - * coding: IG_C_gene, IG_D_gene, IG_J_gene, IG_V_gene, - TR_C_gene, TR_D_gene, TR_J_gene, TR_V_gene - polymorphic_pseudogene, protein_coding - - * pseudo: IG_C_pseudogene, IG_J_pseudogene, IG_V_pseudogene, TR_J_pseudogene, TR_V_pseudogene, - pseudogene - - * nonCoding: 3prime_overlapping_ncrna, Mt_rRNA, Mt_tRNA, antisense, lincRNA, miRNA, - misc_RNA, processed_transcript, rRNA, sense_intronic, sense_overlapping, - snRNA, snoRNA -*/ - +/* Find GENCODE color for gene type. */ { initGeneColors(hvg); -char *geneType = geneBed->transcriptClass; - -/* keep backwards compatibility with tables (V4 having transcript classes in table) */ -if (geneType == NULL) +char *geneClass = gtexGeneClass(geneBed); +if (geneClass == NULL) return statusColors.unknown; - -if (sameString(geneType, "coding") || sameString(geneType, "protein_coding") || - sameString(geneType, "polymorphic_pseudogene") || endsWith(geneType, "_gene")) +if (sameString(geneClass, "coding")) return statusColors.coding; - -if (sameString(geneType, "pseudo") || sameString(geneType, "pseudogene") || - endsWith(geneType, "_pseudogene")) - return statusColors.nonCoding; - -// A bit of a cheat here -- better a mapping table +if (sameString(geneClass, "nonCoding")) return statusColors.nonCoding; +if (sameString(geneClass, "pseudo")) + return statusColors.pseudo; +return statusColors.unknown; } /***********************************************/ /* Cache tissue info */ struct gtexTissue *getTissues() /* Get and cache tissue metadata from database */ { static struct gtexTissue *gtexTissues = NULL; if (!gtexTissues) gtexTissues = gtexGetTissues(); return gtexTissues; } @@ -553,31 +532,31 @@ } double viewMax = (double)cartUsualIntClosestToHome(cart, tg->tdb, FALSE, GTEX_MAX_LIMIT, GTEX_MAX_LIMIT_DEFAULT); double maxMedian = ((struct gtexGeneExtras *)tg->extraUiData)->maxMedian; return valToClippedHeight(maxExp, maxMedian, viewMax, gtexMaxGraphHeight(), extras->doLogTransform); } static void gtexGeneDrawAt(struct track *tg, void *item, struct hvGfx *hvg, int xOff, int y, double scale, MgFont *font, Color color, enum trackVisibility vis) /* Draw tissue expression bar graph over gene model. Optionally, draw a second graph under gene, to compare sample sets */ { struct gtexGeneExtras *extras = (struct gtexGeneExtras *)tg->extraUiData; struct gtexGeneInfo *geneInfo = (struct gtexGeneInfo *)item; struct gtexGeneBed *geneBed = geneInfo->geneBed; -// Color in dense mode using transcriptClass +// Color in dense mode using geneClass Color statusColor = getGeneClassColor(hvg, geneBed); if (vis != tvFull && vis != tvPack) { bedDrawSimpleAt(tg, geneBed, hvg, xOff, y, scale, font, statusColor, vis); return; } int heightPer = tg->heightPer; int graphX = gtexGraphX(geneBed); if (graphX < 0) return; // draw gene model int topGraphHeight = gtexGeneGraphHeight(tg, geneInfo, TRUE); topGraphHeight = max(topGraphHeight, tl.fontHeight);