c31ac1a756d1c425572e3d7ba569c61453dcdd09 kate Tue Oct 20 18:13:21 2015 -0700 Add X axis labels, rotated 45 degrees. Adjust colors, line styles,e tc. refs #15645 diff --git src/hg/hgc/gtexClick.c src/hg/hgc/gtexClick.c index c224b2e..5734f12 100644 --- src/hg/hgc/gtexClick.c +++ src/hg/hgc/gtexClick.c @@ -12,30 +12,31 @@ #include "rainbow.h" #include "hvGfx.h" #include "gtexUi.h" #include "gtexGeneBed.h" #include "gtexTissue.h" #include "gtexSampleData.h" boolean doLogTransform = FALSE; struct gtexGeneBed *gtexGene = NULL; struct tissueSampleVals /* RPKM expression values for multiple samples */ { struct tissueSampleVals *next; + char *name; /* GTEx tissue name */ char *description; /* GTEx tissue description */ int color; /* GTEx tissue color */ int count; /* number of samples */ double *vals; /* RPKM values */ double min, max; /* minimum, maximum value */ double q1, median, q3; /* quartiles */ struct slDouble *valList; /* used to create val array */ }; int cmpTissueSampleValsMedianScore(const void *va, const void *vb) /* Compare RPKM scores */ { const struct tissueSampleVals *a = *((struct tissueSampleVals **)va); const struct tissueSampleVals *b = *((struct tissueSampleVals **)vb); if (a->median == b->median) @@ -52,48 +53,48 @@ // Create R data frame struct tempName dfTn; trashDirFile(&dfTn, "hgc", "gtexGene", ".df.txt"); FILE *f = fopen(dfTn.forCgi, "w"); if (f == NULL) errAbort("can't create temp file %s", dfTn.forCgi); fprintf(f, "sample\ttissue\trpkm\n"); struct tissueSampleVals *tsv; int i; int sampleId=1; for (tsv = tsvList; tsv != NULL; tsv = tsv->next) { int count = tsv->count; for (i=0; idescription, tsv->vals[i]); + fprintf(f, "%d\t%s\t%0.3f\n", sampleId++, tsv->name, tsv->vals[i]); } fclose(f); // Plot to PNG file struct tempName pngTn; trashDirFile(&pngTn, "hgc", "gtexGene", ".png"); char cmd[256]; // Exec R in quiet mode, without reading/saving environment or workspace safef(cmd, sizeof(cmd), "Rscript --gui=X11 --vanilla --slave gtex/geneBoxplot.R %s %s %s", gtexGene->name, dfTn.forCgi, pngTn.forHtml); int ret = system(cmd); if (ret == 0) { - printf("
\n", pngTn.forHtml); - /*printf("
\n", - pngTn.forHtml, imageWidth, imageHeight); - */ + //printf("
\n", pngTn.forHtml); + printf("
\n", + //pngTn.forHtml, imageWidth, imageHeight); + pngTn.forHtml, 900, 500); } } void d3GtexBoxplot(struct tissueSampleVals *tsvList) { //puts("\n"); //puts("\n"); printf("
\n"); jsIncludeFile("d3.min.js", NULL); jsIncludeFile("d3plus.gtex.js", NULL); jsTrackingVar("geneName", gtexGene->name); jsTrackingVar("geneId", gtexGene->geneId); jsIncludeFile("gtex.js", NULL); } @@ -385,30 +386,31 @@ slAddHead(&tsv->valList, val); } // Fill in tissue descriptions, fill values array and calculate stats for plotting // Then make a list, suitable for sorting by tissue or score struct gtexTissue *tis = NULL, *tissues = gtexGetTissues(); struct tissueSampleVals *tsList = NULL; int i; doLogTransform = cartUsualBooleanClosestToHome(cart, tdb, FALSE, GTEX_LOG_TRANSFORM, GTEX_LOG_TRANSFORM_DEFAULT); if (doLogTransform) maxVal = log10(maxVal+1.0); for (tis = tissues; tis != NULL; tis = tis->next) { tsv = hashMustFindVal(tsHash, tis->name); + tsv->name = tis->name; tsv->description = tis->description; tsv->color = tis->color; int count = tsv->count = slCount(tsv->valList); double *vals = AllocArray(tsv->vals, count); for (i=0; ivalList); if (doLogTransform) vals[i] = log10(val->val+1.0); else vals[i] = val->val; } doubleBoxWhiskerCalc(tsv->count, tsv->vals, &tsv->min, &tsv->q1, &tsv->median, &tsv->q3, &tsv->max); slAddHead(&tsList, tsv);