From f6e50b479db8423cbde21598057429378fd68f26 Mon Sep 17 00:00:00 2001 From: mnshgl0110 Date: Tue, 21 May 2024 17:06:24 +0200 Subject: [PATCH] Added option to adjust line width using base.cfg https://github.com/schneebergerlab/plotsr/issues/15 --- config/base.cfg | 17 +++++++++++------ example/base.cfg | 5 +++++ plotsr/scripts/func.py | 12 ++++++++++-- 3 files changed, 26 insertions(+), 8 deletions(-) mode change 100755 => 100644 config/base.cfg mode change 100755 => 100644 example/base.cfg mode change 100755 => 100644 plotsr/scripts/func.py diff --git a/config/base.cfg b/config/base.cfg old mode 100755 new mode 100644 index 3156977..626c3b4 --- a/config/base.cfg +++ b/config/base.cfg @@ -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 \ No newline at end of file +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 diff --git a/example/base.cfg b/example/base.cfg old mode 100755 new mode 100644 index 2491de2..626c3b4 --- a/example/base.cfg +++ b/example/base.cfg @@ -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 diff --git a/plotsr/scripts/func.py b/plotsr/scripts/func.py old mode 100755 new mode 100644 index 97bfb7c..a14a3aa --- a/plotsr/scripts/func.py +++ b/plotsr/scripts/func.py @@ -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 @@ -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: @@ -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']] @@ -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)