Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
khalid
radsex
Commits
48b1cb18
Commit
48b1cb18
authored
Aug 30, 2017
by
Romain Feron
Browse files
Cleaned up old visualization files
parent
37c7bb92
Changes
3
Hide whitespace changes
Inline
Side-by-side
radseq_analysis/visualization/r_plots.py
deleted
100644 → 0
View file @
37c7bb92
import
os
def
frequencies
(
file
,
output_dir
):
scripts_d
=
''
.
join
(
os
.
path
.
split
(
os
.
path
.
realpath
(
__file__
))[:
-
1
])
cmd
=
(
'Rscript '
+
os
.
path
.
join
(
scripts_d
,
'r_scripts'
,
'frequencies.R'
)
+
' '
+
file
+
' '
+
output_dir
)
os
.
system
(
cmd
)
def
haplotypes
(
file
,
output_dir
,
threshold
):
scripts_d
=
''
.
join
(
os
.
path
.
split
(
os
.
path
.
realpath
(
__file__
))[:
-
1
])
cmd
=
(
'Rscript '
+
os
.
path
.
join
(
scripts_d
,
'r_scripts'
,
'haplotypes.R'
)
+
' '
+
file
+
' '
+
output_dir
+
' '
+
str
(
threshold
))
os
.
system
(
cmd
)
radseq_analysis/visualization/r_scripts/haplotypes.R
deleted
100644 → 0
View file @
37c7bb92
#!/usr/bin/env Rscript
args
=
commandArgs
(
trailingOnly
=
TRUE
)
# test if there is at least one argument: if not, return an error
if
(
length
(
args
)
==
0
)
{
stop
(
"At least one argument must be supplied (input file).n"
,
call.
=
FALSE
)
}
else
if
(
length
(
args
)
!=
3
){
stop
(
"Usage: R haplotypes.R input_file.tsv output_dir treshold"
)
}
suppressMessages
(
library
(
readr
))
suppressMessages
(
library
(
ggplot2
))
suppressMessages
(
library
(
gridExtra
))
file
=
args
[
1
]
output_dir
=
args
[
2
]
threshold
=
args
[
3
]
png_name
=
paste
(
"sex_variable_haplotypes.png"
,
sep
=
''
)
data
<-
suppressMessages
(
read_delim
(
file
,
"\t"
,
col_names
=
TRUE
,
escape_double
=
FALSE
,
trim_ws
=
TRUE
))
names
(
data
)
=
c
(
'Locus'
,
'Male_haplotype'
,
'Male_haplotype_number'
,
'Female_haplotype'
,
'Female_haplotype_number'
,
'Males'
,
'Females'
,
'Male_outliers'
,
'Female_outliers'
,
'Consensus'
)
males
=
data.frame
(
table
(
data
$
Male_haplotype_number
[
which
(
data
$
Male_haplotype_number
>
threshold
)],
data
$
Female_haplotype_number
[
which
(
data
$
Male_haplotype_number
>
threshold
)]))
names
(
males
)
=
c
(
'Males'
,
'Females'
,
'Count'
)
females
=
data.frame
(
table
(
data
$
Male_haplotype_number
[
which
(
data
$
Female_haplotype_number
>
threshold
)],
data
$
Female_haplotype_number
[
which
(
data
$
Female_haplotype_number
>
threshold
)]))
names
(
females
)
=
c
(
'Males'
,
'Females'
,
'Count'
)
g
<-
ggplot
(
males
,
aes
(
x
=
Males
,
y
=
Count
,
fill
=
Females
))
g
=
g
+
geom_bar
(
stat
=
'identity'
,
position
=
position_dodge
(),
colour
=
'black'
)
h
<-
ggplot
(
females
,
aes
(
x
=
Females
,
y
=
Count
,
fill
=
Males
))
h
=
h
+
geom_bar
(
stat
=
'identity'
,
position
=
position_dodge
(),
colour
=
'black'
)
png
(
paste
(
output_dir
,
png_name
,
sep
=
''
),
width
=
1600
,
height
=
1000
,
res
=
130
)
grid.arrange
(
g
,
h
,
ncol
=
2
)
x
=
dev.off
()
radseq_analysis/visualization/visualisation.py
deleted
100644 → 0
View file @
37c7bb92
import
os
from
.
import
r_plots
def
run
(
global_parameters
):
results_dir
=
os
.
path
.
join
(
global_parameters
.
results_dir
,
''
)
print
(
' - Plotting frequencies data'
)
r_plots
.
frequencies
(
global_parameters
.
frequencies_file
,
results_dir
)
print
(
' - Plotting haplotypes data'
)
r_plots
.
haplotypes
(
global_parameters
.
haplotypes_file
,
results_dir
,
global_parameters
.
error_threshold
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment