wig

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2024 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package wig provides functions to read, write, and manipulate wig files. more information on the WIG file format can be found at https://genome.ucsc.edu/goldenPath/help/wiggle.html

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllEqual

func AllEqual(alpha []Wig, beta []Wig) bool

AllEqual returns true if two slices of Wig data structures contain all the same data vales in the same order, false otherwise.

func GoReadToChan

func GoReadToChan(filename string) <-chan Wig

GoReadToChan reads Wig entries from an input filename to a <-chan Wig.

func MakeSkeleton added in v1.0.1

func MakeSkeleton(chromSizes map[string]chromInfo.ChromInfo, defaultValue float64) map[string]Wig

MakeSkeleton creates a fixed-step map[string]Wig, with one Wig entry per chromosome, where the size of the Values slice in each struct is equal to the chromosome length, as specified by an input chromSizes map[string]chromInfo.ChromInfo. 'Skeleton' refers to the fact that the values are uniformly set to a defaultValue, and contain no information.

func Pearson

func Pearson(alpha map[string]Wig, beta map[string]Wig, missing float64, samplingFrequency float64) float64

Pearson calculates the Pearson Correlation Coefficient between two input wig slices. Data values equal to the 'missing' value are ignored. samplingFrequency is a number between 0 and 1. This represents the proportion of bases that are considered for evaluating the PCC.

func Read

func Read(filename string, chromSizeFile string, defaultValue float64) map[string]Wig

Read creates a whole genome wig map, where each key is a chromosome name and the value is the corresponding wig struct. The wig struct values slice is the size of the whole chromosome, as specified by an input chromSizeFile. Positions in the genome where there is no wig coverage are set to a user-specified defaultValue. This function is robust against different step sizes between entries and multiple wig entries per chromosome, but is currently limited to 'fixedStep' beds.

func ReadToChan

func ReadToChan(file *fileio.EasyReader, data chan<- Wig, wg *sync.WaitGroup)

ReadToChan reads from a fileio.EasyReader to send Wig structs to a chan<- Wig. When it has finished reading the file, ReadToChan will call Done on the waitgroup.

func SmoothMap added in v1.0.1

func SmoothMap(w map[string]Wig, windowSize int, missing float64) map[string]Wig

SmoothMap performs moving average smoothing on an input map of Wig structs using a user-specified windowSize and a value that represents missing data in the Wig.

func SortByCoord

func SortByCoord(w []Wig)

SortByCoord sorts in place a slice of Wig structs by their genomic position with secondary sorting by the number of values.

func Write

func Write(filename string, records map[string]Wig)

Write writes an input map[string]Wig to an output filename. Entries in the map will be written in alphanumeric order of the map keys.

func WriteToFileHandle

func WriteToFileHandle(file io.Writer, rec Wig)

WriteToFileHandle is a helper function for Write that writes the Wig data structure to an io.Writer

Types

type Wig

type Wig struct {
	StepType     string
	Chrom        string
	Start        int
	Step         int
	Span         int
	DefaultValue float64 // this will be the value in positions where there is no wig data, alternatively referred to as "MissingValue" in some functions
	Values       []float64
}

Wig stores information on the chromosome location and step properties of Wig data. Individual wig values are stored in the underlying WigValue struct. Can only handle fixedStep wigs.

func NextWig

func NextWig(file *fileio.EasyReader) (Wig, bool)

NextWig returns a Wig struct from an input fileio.EasyReader. Returns a bool that is true when the reader is done.

func Smooth

func Smooth(w Wig, windowSize int, missing float64) Wig

Smooth performs moving average smoothing on an input Wig struct using a user-specified windowSize and a value that represents missing data in the Wig.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL