D4
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
Constants
D4Error = Error
Compatibility name for callers of the former d4binding wrapper.
VERSION = {{ (`shards version /tmp/tmp.jPCGAG/src/src/d4`).chomp.stringify }}
Class methods
build_indexes(path : String | Path, *, track : String | Nil = nil, kinds : Array(IndexKind) = [IndexKind::SecondaryFrames, IndexKind::Sum], control : WriteControl = WriteControl.new) : Nil
Sourcecreate(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
Sourcecreate(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
SourceConvenience method to open a D4 file for reading
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
open(source : Source, *, sync_close : Bool = false, track : String | Nil = nil, options : ReadOptions = ReadOptions.new)
Sourceopen(source : Source, *, sync_close : Bool = false, track : String | Nil = nil, options : ReadOptions = ReadOptions.new, & : File -> T) forall T
SourceNested types
- D4::AggregateIterator(D, R)
- D4::AllocationLimitError
- D4::BinIterator
- D4::BinSummary
- D4::CancelledError
- D4::Chromosome
- D4::ClosedError
- D4::Compression
- D4::CorruptIndexError
- D4::Coverage
- D4::DictType
- D4::Dictionary
- D4::DirectoryEncoder
- D4::Error
- D4::ExactHistogram
- D4::File
- D4::Format
- D4::FormatError
- D4::FrameAddress
- D4::FrameEncoder
- D4::HTTPError
- D4::HTTPSource
- D4::HeaderParser
- D4::Histogram
- D4::HistogramTails
- D4::IOSource
- D4::IncompleteHistogramError
- D4::IndexBuilder
- D4::IndexKind
- D4::IndexPolicy
- D4::IndexPrecisionError
- D4::Interval(T)
- D4::IntervalIterator
- D4::LocalSource
- D4::Matrix
- D4::MemorySource
- D4::Metadata
- D4::MissingIndexError
- D4::ParallelWork
- D4::RangeNotSupportedError
- D4::RangeRecord
- D4::RawInterval
- D4::ReadOptions
- D4::Reducers
- D4::Region
- D4::RegionResult(T)
- D4::Rounding
- D4::Row
- D4::ScaledInterval
- D4::ScaledIntervalIterator
- D4::ScaledMatrix
- D4::ScaledRow
- D4::ScaledTrack
- D4::ScaledValueIterator
- D4::SecondaryFrameIndex
- D4::SecondaryMetadata
- D4::SecondaryMetadataParser
- D4::SecondaryPartition
- D4::SecondaryRecordIterator
- D4::SecondaryTable
- D4::Source
- D4::SourceChangedError
- D4::SumIndex
- D4::Summary
- D4::Track
- D4::TrackSelectionError
- D4::UnexpectedEOFError
- D4::UnknownChromosomeError
- D4::UnsupportedFeatureError
- D4::ValueIterator
- D4::ValueScanner
- D4::WriteControl
- D4::WriteOptions
- D4::WriteProgress
- D4::WriteStage
- D4::Writer