CircleGraph - Scripts

Some general recommendations how to organize the scrpt for a complex graph.

Design

The script is processed line by line and translated into a hierarchic object model.
THe model does not necessarily take respect of the order of the script commands

Therefore, it is recommended to build a script in the order:











Variables

Imagine you generate a graph which shall display Methylation M-values in muliple segments as line graphs.
You want to use same scaling in all segments, but scale may depend on the data.

Therefore you could insert a "scale=min,max" commnand in each XY-series block.
But how to change all in one go ?

For such purposes you may use variables.

CircleGraph uses 10 fix named variables:
$0,$1,...,$10

Asssign a value to a variable:
define=$1:any value/text


In all sub-sequent script lines, occurence of $1 will be replaced by the defined text (here: "any value/text").

if you do not want to use a varaible any longer, un-define it:
undefine=$1
Now the variable is empty.
If a script line contains "$1" nothing would be replace - as there is nothing defined as replacement.
Variables may be defiend, re-defined or un-defined as often as you want.


Have a careful look on validity and and scope of vriables, especially when combining / including different script parts.

E.g. in the Chromosomal G-Banding script fragment, variables are used to dimension scaling ticks, position, ... with variables $1,$2,...
Those might conflict with variable definitions you have in a script into which G-banding is copy/pasted/included. Therefore it might be helpful to just bakcup your variables before e.g. encluding a subscript and restoring them afterwards:
# any script commands
...
# backup all variables
variables.push
include=my_subscript.txt
# restore variables
variables.pop
...

Variale commands:
Command 
define=$x:value Define the value of a variable:
- $x = variable name e.g. "$0" or "$1" or "$2" ... "$9"
- value = number or text you assign to a variable
E.g. define=$1:test_value would assign the text "test_value to variable "$1".
undefine=$x Reset the value of a variable. A undefined variable will not be used.
- $x = variable name e.g. "$0" or "$1" or "$2" ... "$9"
variables.name=name Define a name for the present variable set.
You may use this name to lateron recall a named variable set from the variable stack.
variables.clearall Un-define all variables..
variables.push Back-up all variables internally onto a variables stack.
You have 100 backup levels !
variables.pop Recall last backed-up set of variables from the variables stack.
variables.restorebyid=ID Recall a previously backed-up set of variables from the variables stack, using its position in the stack.
variables.restorebyname=name Recall a previously backed-up set of variables from the variables stack, using its position in the stack.
variables.dump Show all presently set variable's values in the Info/Log tab-sheet.











Run control

When building complicated graphs it may be helpful to split the script
into subunits.






Include scripts

E.g. You want to generate a genome wide graph with G-banding ideogram in the last band.

Thus you could generate a sub-script (e.g. "d:\CG-Scripts\G-Banding.txt")

Take care, your graph is able to handle the include-script.
In our case, the target band should have at lest 24 segments.

You may include the G-banding script into your main script:
# define band where G-banding will be inserted
band=band:5
include=d:\CG-Scripts\G-Banding.txt

Now the code for the G-Banding will be plotted onto defined band=5






Goto - Label

When writing scripts it may be helpful to just skip well working parts of the graph and concentrate on the new gimmicks

Thus you may define to just jump over the already working part of the script:
# basic graph band/segment definitions
....
Goto=Band3
Label=Band1
# all features from band1
...
Label=Band2
# all features from band2
....
Label=Band3
# insert the new features for band3
...






Exit