Skip to content

Commit

Permalink
ChronQC 1.0.2 version changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nilesh-tawari committed Aug 3, 2017
1 parent b363c2c commit 381bb6d
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 33 deletions.
16 changes: 2 additions & 14 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,5 @@
History
-------
1.0.2: Changes

* Added stacked bar plot and bar and line plot
* Bug fixes
* Error handling

1.0.1: Features

* Designed for quality control based on historical data
* Generates interactive time-series plots for various metrics, allowing comparison of the current run to historical runs
* Record users' notes and corrective actions directly onto the graphs for long-term record-keeping
* Provides highly customizable different chart types
* Supports customized database for plotting
* Works with output of MultiQC
July 13, 2017 - Released version 1.0.1 software package
July 13, 2017 - Released version 1.0.0 software package
15 changes: 11 additions & 4 deletions chronqc/chronqc_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def absolute_threshold(df, column, lower_threshold=np.nan, upper_threshold=np.na
return df_bq


def box_whisker_plot(df, ColumnName, Type=''):
def box_whisker_plot(df, ColumnName, Type='', lower_threshold=np.nan, upper_threshold=np.nan):
"""
(df) -> df
generate box plot data form the df
Expand Down Expand Up @@ -337,10 +337,13 @@ def box_whisker_plot(df, ColumnName, Type=''):
'Run', 'Sample'])
df_bp['Sample'].fillna('NA', inplace=True)
df_bp['Run'].fillna('NA', inplace=True)
# set threshold
df_bp['lower_threshold'] = float(lower_threshold)
df_bp['upper_threshold'] = float(upper_threshold)
# Add dumy dates at begnining and end of dataframe
df_bp = add_dates(df_bp)
# Format data for writing to html file
df_bp['Data'] = df_bp[['Date', '25%', '75%', 'Upper_whisker', 'Lower_whisker', '50%', 'Outlier']].values.tolist()
df_bp['Data'] = df_bp[['Date', '25%', '75%', 'Upper_whisker', 'Lower_whisker', '50%', 'Outlier', 'upper_threshold', 'lower_threshold']].values.tolist()
df_bp = format_date_names(df_bp)
return df_bp

Expand Down Expand Up @@ -682,14 +685,18 @@ def main(args):
chart_title = chart["chart_properties"].get('chart_title', t)
y_label = chart["chart_properties"].get('y_label', y)
Type = chart["chart_properties"].get("Type", '')
lower_threshold = chart["chart_properties"].get("lower_threshold", np.nan)
upper_threshold = chart["chart_properties"].get("upper_threshold", np.nan)
js_tmpl = string.Template(open(op.join(templates_dir, "box_whisker_plot.txt")).read())
if not column_name in df.columns:
logger.critical("FATAL: no {0} column found in {1}".format(column_name, table))
sys.exit(1)
if Type != '':
df_chart = box_whisker_plot(df, column_name, Type=Type)
df_chart = box_whisker_plot(df, column_name, Type=Type,
lower_threshold=lower_threshold,
upper_threshold=upper_threshold)
else:
df_chart = box_whisker_plot(df, column_name)
df_chart = box_whisker_plot(df, column_name, lower_threshold=lower_threshold, upper_threshold=upper_threshold)
logger.info("For {0}: {1} data points will be written to html".format(chart_id, len(df_chart)))
elif chart['chart_type'] == 'time_series_with_bar_line_plot':
if categories == '':
Expand Down
2 changes: 1 addition & 1 deletion chronqc/templates/base_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@
function candlePlotter(e) {

if (e.seriesIndex !== 0) return;
var BAR_WIDTH = 12;
var BAR_WIDTH = 18;
var prices = [];
var price;
var sets = e.allSeriesPoints;
Expand Down
41 changes: 33 additions & 8 deletions chronqc/templates/box_whisker_plot.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
document.getElementById("$divname"),
$dataname,
{
labels: ["Date","1st Quantile","3rd Quantile","Upper Whisker", "Lower Whisker", "Median","Scatter"],
labels: ["Date","1st Quantile","3rd Quantile","Upper Whisker", "Lower Whisker", "Median","Scatter", "Upper Threshold", "Lower Threshold"],
labelsDiv: document.getElementById("$labeldiv"),
labelsSeparateLines: true,
showRangeSelector: true,
Expand Down Expand Up @@ -59,8 +59,18 @@
+ "<br><b>Median:</b> ".fontcolor("#7e04a3") + data[5]
+ "<br><b>1st Quantile:</b> ".fontcolor("#4DD8AD") + data[1]
+ "<br><b>Lower Whisker:</b> ".fontcolor("#f442d1") + data[4]
+ "<br><b>Outlier:</b> ".fontcolor("#0080ff") + data[6]


if (data[6] != null){
text = text + "<br><b>Outlier:</b> ".fontcolor("#0080ff") + data[6]
}

if (data[7] != null){
text = text + "<br><b>Upper Threshold:</b> ".fontcolor("#ff0000") + data[7]
}

if (data[8] != null){
text = text + "<br><b>Lower Threshold:</b> ".fontcolor("#ff0000") + data[8]
}

if (run[1].length == 0){return text}
else if (run[1].length != 0){
Expand Down Expand Up @@ -95,6 +105,18 @@
color: "#0080ff",
plotter: Dygraph.Plotters.linePlotter,
strokeWidth: 0
},
"Upper Threshold" : {
plotter: Dygraph.Plotters.linePlotter,
strokePattern: Dygraph.DASHED_LINE ,
color: "#ff0000",
strokeWidth: 2,
},
"Lower Threshold" : {
plotter: Dygraph.Plotters.linePlotter,
strokePattern: Dygraph.DASHED_LINE ,
color: "#ff0000",
strokeWidth: 2,
}
},
underlayCallback: function(canvas, area, g) {
Expand Down Expand Up @@ -135,11 +157,14 @@

},
pointClickCallback: function(e, point) {
run = $runname[point.idx][0]
date = $dataname[point.idx][0]
date = moment(date).format("DD-MM-YYYY")
//copyToClipboard(run)
makeQuery(run,date)
if($dataname[point.idx][6] == null)return;
else{
run = $runname[point.idx][0]
date = $dataname[point.idx][0]
date = moment(date).format("DD-MM-YYYY")
//copyToClipboard(run)
makeQuery(run,date)
}
},
}
);
Expand Down
2 changes: 1 addition & 1 deletion docs/plots/time_series_with_stacked_bar_plot.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Example JSON entry (full) to plot all samples excluding NTC ::
"table_name": "VCS_Stats_Summary",
"include_samples": "all",
"exclude_samples": "NTC",
"chart_type": "time_series_with_bar_line_plot",
"chart_type": "time_series_with_stacked_bar_plot",
"chart_properties": {
"chart_title": "Monthly bar and line plot for Gene (KRAS, KIT, BRAF, PDGFRA, NRAS)",
"y_value": "Gene",
Expand Down
6 changes: 3 additions & 3 deletions docs/plots/timeseries_absolute_threshold.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ Chart Properties
| | | E.g. 100. |
+------------------+-----------------------------------+-----------------------------------------------------------------------------------------------+
| upper_threshold | Integer (Optional) | This is used to create upper threshold line on the chart. |
| | | E.g.300. |
| | | E.g. 300. |
+------------------+-----------------------------------+-----------------------------------------------------------------------------------------------+
| per_sample | Boolean (Optional) | Plot per sample graph. Default is False. |
| | | If set to True per sample graph will be plotted. |
| per_sample | Boolean (Optional) | Plot per sample graph. Default is "False". |
| | | If set to "True" per sample graph will be plotted. |
+------------------+-----------------------------------+-----------------------------------------------------------------------------------------------+


Expand Down
11 changes: 9 additions & 2 deletions docs/plots/timeseries_box_whisker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ Chart Properties
| Type | String (Optional) | This is used to select subset of rows from the SQLite table's "Type" columns. |
| | | E.g. "SNPs". |
+------------------+-----------------------------------+-----------------------------------------------------------------------------------------------+

| lower_threshold | Integer (Optional) | This is used to create lower threshold line on the chart. |
| | | E.g. 100. |
+------------------+-----------------------------------+-----------------------------------------------------------------------------------------------+
| upper_threshold | Integer (Optional) | This is used to create upper threshold line on the chart. |
| | | E.g. 300. |
+------------------+-----------------------------------+-----------------------------------------------------------------------------------------------+

Example JSON entry (minimum)::

Expand All @@ -56,7 +61,9 @@ Example JSON entry (full) to plot all samples excluding HCT15 and NTC ::
"chart_title": "Bcftools Stats Number Of Snps Monthly Box-and-Whisker Plot",
"y_value": "Number",
"Type": "SNPs",
"y_label": "Bcftools Stats Number Of Snps"
"y_label": "Bcftools Stats Number Of Snps",
"lower_threshold": 10000,
"upper_threshold": 15000
}
}
]
Expand Down
2 changes: 2 additions & 0 deletions examples/custom_db_example/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@
"chart_title": "Number of indels found in Samples Over Time",
"y_value": "Number",
"Type": "Indels",
"lower_threshold": 1521,
"upper_threshold": 1960,
"y_label": "Number of indels found in each sample"
}
},
Expand Down

0 comments on commit 381bb6d

Please sign in to comment.