module D4

Overview

D4 format library for Crystal

D4 is a format designed to store quantitative data associated with genomic intervals. It provides efficient compression and fast random access for depth data and similar genomic quantitative information.

Usage

Reading D4 files

D4.open("data.d4") do |file|
  puts file.chromosomes.map(&.name)
  puts file.mean("chr1", 1000, 2000)
  file.each_interval("chr1", 1000, 2000) do |interval|
    puts "#{interval.left}-#{interval.right}: #{interval.value}"
  end
end

Writing D4 files

D4.create("output.d4", chromosomes: [D4::Chromosome.new("chr1", 1000_i64)],
  dictionary: D4::Dictionary.new(0_i32, 8_i32)) do |writer|
  writer.write_values("chr1", 0, [1_i32, 2_i32, 3_i32])
end

Defined in:

d4.cr
d4/bins.cr
d4/errors.cr
d4/file.cr
d4/format.cr
d4/http.cr
d4/index.cr
d4/index_builder.cr
d4/matrix.cr
d4/reducers.cr
d4/scaled.cr
d4/source.cr
d4/stats.cr
d4/track.cr
d4/types.cr
d4/version.cr
d4/write_control.cr
d4/writer.cr

Constant Summary

D4Error = Error

Compatibility name for callers of the former d4binding wrapper.

VERSION = {{ (`shards version /home/runner/work/d4.cr/d4.cr/src/d4`).chomp.stringify }}

Class Method Summary

Class Method Detail

def self.build_indexes(path : String | Path, *, track : String | Nil = nil, kinds : Array(IndexKind) = [IndexKind::SecondaryFrames, IndexKind::Sum], control : WriteControl = WriteControl.new) : Nil #

[View source]
def self.create(path : String | Path, *, chromosomes : Array(Chromosome), dictionary : Dictionary = Dictionary.new(0, 64), denominator : Float64 = 1.0, default_value : Int32 = 0, options : WriteOptions = WriteOptions.new, control : WriteControl = WriteControl.new) : Writer #

[View source]
def self.create(path : String | Path, *, chromosomes : Array(Chromosome), dictionary : Dictionary = Dictionary.new(0, 64), denominator : Float64 = 1.0, default_value : Int32 = 0, options : WriteOptions = WriteOptions.new, control : WriteControl = WriteControl.new, & : Writer -> T) : T forall T #

[View source]
def self.open(path : String | Path, *, track : String | Nil = nil, options : ReadOptions = ReadOptions.new) #

Convenience method to open a D4 file for reading


[View source]
def self.open(path : String | Path, *, track : String | Nil = nil, options : ReadOptions = ReadOptions.new, & : File -> T) forall T #

Convenience method to open a D4 file with a block


[View source]
def self.open(source : Source, *, sync_close : Bool = false, track : String | Nil = nil, options : ReadOptions = ReadOptions.new) #

[View source]
def self.open(source : Source, *, sync_close : Bool = false, track : String | Nil = nil, options : ReadOptions = ReadOptions.new, & : File -> T) forall T #

[View source]
def self.open(io : IO, *, sync_close : Bool = false, track : String | Nil = nil, options : ReadOptions = ReadOptions.new) #

[View source]
def self.open(io : IO, *, sync_close : Bool = false, track : String | Nil = nil, options : ReadOptions = ReadOptions.new, & : File -> T) : T forall T #

[View source]