SnpArrays.jl
SnpArrays.jl copied to clipboard
Repeatedly filtering Plink files based on integer indices
When using filter()
with integer indices multiple times, the result is overwritten on the existing filtered SnpArray
.
versioninfo()
Julia Version 1.0.1
Commit 0d713926f8 (2018-09-29 19:05 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.0 (ORCJIT, ivybridge)
const mouse = SnpArray(SnpArrays.datadir("mouse.bed"))
s0 = SnpArrays.filter(SnpArrays.datadir("mouse"), 1:2, 1:5)
s0
2×5 SnpArray:
0x02 0x02 0x02 0x02 0x03
0x02 0x02 0x03 0x02 0x02
s1 = SnpArrays.filter(SnpArrays.datadir("mouse"), 1:2, 1:3)
s2 = SnpArrays.filter(SnpArrays.datadir("mouse"), 1:2, 4:5)
#s3 = SnpArrays.filter(SnpArrays.datadir("mouse"), 3:4, 1:3);
s1
2×3 SnpArray:
0x02 0x03 0x00
0x02 0x02 0x00
s2
2×2 SnpArray:
0x02 0x03
0x02 0x02
s0
2×5 SnpArray:
0x02 0x03 0x00 0x00 0x00
0x02 0x02 0x00 0x00 0x00
One workaround is to make a copy in memory:
s0 = copy(SnpArrays.filter(SnpArrays.datadir("mouse"), 1:2, 1:5))
s1 = SnpArrays.filter(SnpArrays.datadir("mouse"), 1:2, 1:3)
s2 = SnpArrays.filter(SnpArrays.datadir("mouse"), 1:2, 4:5)
julia> s0
2×5 Array{UInt8,2}:
0x02 0x02 0x02 0x02 0x03
0x02 0x02 0x03 0x02 0x02
Though I'm not sure if this is expected behavior..
Oh, I got it. The destination file (default argument is used) is unchanged for each filtering. Maybe we can change the default name each time the filter
function is called?