BioJulia系列-BigWig

原文戳我

Out of date 该工具包似乎有点过时, 但是因为该包内容和方法比较简单, 可能也还不会影响使用。

提供了对BigWig格式的I/O:

  • BigWig.Reader

  • BigWig.Writer

  • BigWig.Record

julia

# I/O
# Import the BigWig module.
using BigWig

# Open a bigWig file (e.g. mapping depth or coverage).
reader = open(BigWig.Reader, "data.cov.bw")

# Iterate over records overlapping with a query interval.
for record in eachoverlap(reader, Interval("Chr2", 5001, 6000))
    # Extract the start position, end position and value of the record.
    startpos = BigWig.chromstart(record)
    endpos = BigWig.chromend(record)
    value = BigWig.value(record)
    # and do something...
end

# Finally, close the reader.
close(reader)

reader = open(BigWig.Reader, "data.cov.bw")
for record in reader
    # ...
end
close(reader)

# Open an output file.
file = open("data.cov.bw", "w")

# Initialize a bigWig writer.
writer = BigWig.Writer(file, [("chr1", 2000), ("chr2", 1000)])

# Write records.
write(writer, ("chr1",   1, 100, 1.0))
write(writer, ("chr1", 101, 200, 2.1))
# ...
write(writer, ("chr2",  51, 150, 3.2))

# Close the writer (this closes the file, too).
close(writer)

julia

API

函数描述
BigWig.chrom(record::Record)::String获取区间的chr name
BigWig.chromid(record::Record)::UInt32获取区间的chr ID
BigWig.chromstart(rcd)::Int获取区间的start
BigWig.chromend(rcd)::Int获取区间的end
BigWig.value(rcd)::Float32获取区间的value值
BigWig.values(reader, chr, range)::Vector{Float32}获取指定区间的value向量
BigWig.values(reader, interval::Interval)::Vector{Float32}获取指定区间的value向量
BigWig.chromlist获取染色体的(name, length)对
BigWig.coverage(reader, chr, start, end; usezoom=false)::Int计算指定区间的coverage
BigWig.maximum(reader, chr, start, end; usezoom=false)::Float32计算指定区间中value的最大值
BigWig.minimum(reader, chr, start, end; usezoom=false)::Float32计算区间中value的最小值
BigWig.mean(reader, chr, start, end; usezoom=false)::Float32计算区间中value的平均值
BigWig.std(reader, chr, start, end; usezoom=false)::Float32计算区间中value的标准差