Commit fc96e206 authored by Romain Feron's avatar Romain Feron
Browse files

Fixed bug in heatmap R script (in case species name is not specified)

parent f296d9bb
......@@ -21,12 +21,15 @@ def analysis(input_dir=None,
parameters = Parameters(files_dir=input_dir,
output_file_path=output_file_path)
species = None
if popmap_file_path:
load_popmap(popmap_file_path, parameters)
species = os.path.split(popmap_file_path)[1]
species = os.path.splitext(species)[0]
species = '_'.join(s for s in species.split('_')[:-1])
parameters.species = species
if len(species.split('_')) > 1:
species = '_'.join(s for s in species.split('_')[:-1])
parameters.species = species
if positions_file_path:
load_positions_list(positions_file_path, parameters)
......
......@@ -6,6 +6,7 @@ def haplotypes(input_file_path, output_file_path, species_name):
scripts_d = ''.join(os.path.split(os.path.realpath(__file__))[:-1])
cmd = ('Rscript ' + os.path.join(scripts_d, 'r_scripts', 'heatmap.R') +
' ' + input_file_path +
' ' + output_file_path +
' ' + species_name)
' ' + output_file_path)
if species_name:
cmd += ' ' + species_name
os.system(cmd)
......@@ -2,8 +2,12 @@
args = commandArgs(trailingOnly=TRUE)
# test if there is at least one argument: if not, return an error
if (length(args) != 3){
stop("Usage: R frequencies.R input_file.tsv output_file.png species_name")
if (length(args) > 3 | length(args) < 2){
stop("Usage: R heatmap.R input_file.tsv output_file.png [species_name]")
} else if (length(args == 3)) {
species_name = args[3]
} else if (length(args == 2)) {
species_name="none"
}
suppressMessages(require(readr))
......@@ -11,7 +15,6 @@ suppressMessages(require(ggplot2))
input_file_path = args[1]
output_file_path = args[2]
species_name = args[3]
g_legend<-function(a.gplot){
tmp <- ggplot_gtable(ggplot_build(a.gplot))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment