5593175b35ed5abf3ac564ab716869c64593cb40 kate Wed May 3 08:44:31 2017 -0700 Make data download link more useful ? It now retrieves data frame. The full matrix and sample file urls can live in track description. refs #18736 diff --git src/hg/hgc/barChartClick.c src/hg/hgc/barChartClick.c index 0b525e9..e1689ce 100644 --- src/hg/hgc/barChartClick.c +++ src/hg/hgc/barChartClick.c @@ -277,36 +277,34 @@ return vals; } static char *makeDataFrame(char *track, struct barChartItemData *vals) /* Create R data frame from sample data. This is a tab-sep file, one row per sample. Return filename. */ { // Create data frame with columns for sample, category, value */ struct tempName dfTn; trashDirFile(&dfTn, "hgc", "barChart", ".df.txt"); FILE *f = fopen(dfTn.forCgi, "w"); if (f == NULL) errAbort("can't create temp file %s", dfTn.forCgi); fprintf(f, "sample\tcategory\tvalue\n"); -int i = 0; struct barChartItemData *val; for (val = vals; val != NULL; val = val->next) { - // NOTE: don't actually need sample ID here -- just use a unique int - fprintf(f, "%d\t%s\t%0.3f\n", i++, val->category, val->value); + fprintf(f, "%s\t%s\t%0.3f\n", val->sample, val->category, val->value); } fclose(f); return cloneString(dfTn.forCgi); } char *makeColorFile(struct trackDb *tdb) /* Make a file with category + color */ { struct tempName colorTn; trashDirFile(&colorTn, "hgc", "barChartColors", ".txt"); FILE *f = fopen(colorTn.forCgi, "w"); if (f == NULL) errAbort("can't create temp file %s", colorTn.forCgi); struct barChartCategory *categs = barChartUiGetCategories(database, tdb); struct barChartCategory *categ; @@ -383,23 +381,26 @@ printf("<b>Genomic position: " "</b>%s <a href='%s&db=%s&position=%s%%3A%d-%d'>%s:%d-%d</a><br>\n", database, hgTracksPathAndSettings(), database, chartItem->chrom, chartItem->chromStart+1, chartItem->chromEnd, chartItem->chrom, chartItem->chromStart+1, chartItem->chromEnd); printf("<b>Strand: </b> %s\n", chartItem->strand); char *matrixUrl = NULL, *sampleUrl = NULL; struct barChartItemData *vals = getSampleVals(tdb, chartItem, &matrixUrl, &sampleUrl); if (vals != NULL) { // Print boxplot puts("<p>"); char *df = makeDataFrame(tdb->table, vals); char *colorFile = makeColorFile(tdb); printBoxplot(df, item, chartItem->name2, units, colorFile); +/* if (matrixUrl != NULL) printf("<br>View <a href='%s'>data matrix</a> and <a href='%s'>sample file</a>\n", matrixUrl, sampleUrl); +*/ + printf("<br><a href='%s'>View data for all samples</a>\n", df); } puts("<br>"); printTrackHtml(tdb); }