Skip to content

Commit

Permalink
Added option to adjust line width using base.cfg #15
Browse files Browse the repository at this point in the history
  • Loading branch information
mnshgl0110 committed May 21, 2024
1 parent 2ac7ba0 commit f6e50b4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
17 changes: 11 additions & 6 deletions config/base.cfg
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
## COLOURS and transparency for alignments (syntenic, inverted, translocated, and duplicated)
syncol:#DEDEDE
syncol:#CCCCCC
invcol:#FFA500
tracol:#9ACD32
dupcol:#00BBFF
synlwd:0 ## Line width for syntenic annotations
invlwd:0.1 ## Line width for inversions
tralwd:0.1 ## Line width for translocations
duplwd:0.1 ## Line width for duplications
alpha:0.8

## Margins and dimensions:
chrmar:0.1 ## Adjusts the gap between chromosomes and tracks. Higher values leads to more gap
exmar:0.1 ## Extra margin at the top and bottom of plot area
marginchr:0.1 ## Margin between adjacent chromosomes when using --itx

## LEGEND
legend:T ## To plot legend use T, use F to not plot legend
genlegcol:-1 ## Number of columns for genome legend, set -1 for automatic setup
bbox:0,1.01,0.5,0.3 ## [Left edge, bottom edge, width, height]
## bbox:[0, 1.1, 0.5, 0.3] ## For vertical chromosomes (using -v option)
bboxmar:0.5 ## Margin between genome and annotation legends
legend:T ## To plot legend use T, use F to not plot legend
genlegcol:-1 ## Number of columns for genome legend, set -1 for automatic setup
bbox:0,1.01,0.5,0.3 ## [Left edge, bottom edge, width, height]
bbox_v:0,1.1,0.5,0.3 ## For vertical chromosomes (using -v option)
bboxmar:0.5 ## Margin between genome and annotation legends
5 changes: 5 additions & 0 deletions example/base.cfg
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ syncol:#CCCCCC
invcol:#FFA500
tracol:#9ACD32
dupcol:#00BBFF
synlwd:0 ## Line width for syntenic annotations
invlwd:0.1 ## Line width for inversions
tralwd:0.1 ## Line width for translocations
duplwd:0.1 ## Line width for duplications
alpha:0.8

## Margins and dimensions:
chrmar:0.1 ## Adjusts the gap between chromosomes and tracks. Higher values leads to more gap
exmar:0.1 ## Extra margin at the top and bottom of plot area
marginchr:0.1 ## Margin between adjacent chromosomes when using --itx

## LEGEND
legend:T ## To plot legend use T, use F to not plot legend
Expand Down
12 changes: 10 additions & 2 deletions plotsr/scripts/func.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ def readbasecfg(f, v):
cfg['invcol'] = '#FFA500'
cfg['tracol'] = '#9ACD32'
cfg['dupcol'] = '#00BBFF'
cfg['synlwd'] = 0
cfg['invlwd'] = 0.1
cfg['tralwd'] = 0.1
cfg['duplwd'] = 0.1
cfg['alpha'] = 0.8
# Set chromosome margins
cfg['chrmar'] = 0.1
Expand Down Expand Up @@ -230,7 +234,7 @@ def readbasecfg(f, v):
logger.error("Error in using colour: {} for {}. Use correct hexadecimal colours or named colours defined in matplotlib (https://matplotlib.org/stable/gallery/color/named_colors.html). Using default value.".format(line[1], line[0]))
continue
cfg[line[0]] = line[1]
elif line[0] in ['alpha', 'chrmar', 'exmar', 'bboxmar', 'genlegcol', 'marginchr']:
elif line[0] in ['synlwd', 'invlwd', 'tralwd', 'duplwd', 'alpha', 'chrmar', 'exmar', 'bboxmar', 'genlegcol', 'marginchr']:
try:
float(line[1])
except ValueError:
Expand Down Expand Up @@ -1572,6 +1576,10 @@ def annotodict(anno):
'INV': cfg['invcol'],
'TRANS': cfg['tracol'],
'DUP': cfg['dupcol']}
lwddict = {'SYN': cfg['synlwd'],
'INV': cfg['invlwd'],
'TRANS': cfg['tralwd'],
'DUP': cfg['duplwd']}
# df['col'] = [coldict[c] for c in df['type']]
labdict = {'SYN': 'Syntenic', 'INV': 'Inversion', 'TRANS': 'Translocation', 'DUP': 'Duplication'}
df['lab'] = [labdict[c] for c in df['type']]
Expand All @@ -1586,7 +1594,7 @@ def annotodict(anno):
for row in df.itertuples():
if row.anno == '-':
newcol.append(coldict[row.type])
newlw.append(0 if row.type == 'SYN' else 0.1)
newlw.append(lwddict[row.type])
newz.append(0 if row.type == 'SYN' else 1)
else:
anno = annotodict(row.anno)
Expand Down

0 comments on commit f6e50b4

Please sign in to comment.