Documentation ¶
Overview ¶
Package matrix is a library to load sparse matrices from single-cell data and/or mtx and COO format and create efficient indexing.
Index ¶
- Variables
- func GetRandomBootstrapIndex(arr []uint, downsample int) (index []uint)
- func LoadIndexFileToIndex(fname utils.Filename, downcase bool, refMapping map[string]uint) (celliddict map[string]uint, maxIndex int)
- func LoadPeakDictsToIndex(fname utils.Filename, sepIn, sepOut string) (featiddict map[string]uint, maxIndex int)
- func Mean(arr []float64, size int) (mean float64)
- func Std(arr []float64, mean float64, size int) (std float64)
- func TestStringToPeak(str string) error
- func TtestPval(mean, std float64, size int) (pval float64)
- type Attributes
- type Format
- type MatColFloatHash
- type MatColHash
- func (mc *MatColHash) Get(ygi, xgi uint) bool
- func (mc *MatColHash) GetCol(ygi uint) []bool
- func (mc *MatColHash) GetDim() (xDim, yDim int)
- func (mc *MatColHash) GetIndex(ygi uint) uint
- func (mc *MatColHash) GetRow(ygi uint) map[uint]bool
- func (mc *MatColHash) GetRowDense(ygi uint) (vect []bool)
- func (mc *MatColHash) Init(matCol *[]map[uint]bool, xDim uint)
- func (mc *MatColHash) InitDense(matColDense [][]bool)
- func (mc *MatColHash) IsDense() bool
- func (mc *MatColHash) Len(ygiIndex uint) int
- func (mc *MatColHash) RmDense()
- func (mc *MatColHash) ToDense()
- func (mc *MatColHash) ToDenseFromSubset(ygis []uint) (newYgis []uint)
- func (mc *MatColHash) ToDenseFromSubsetAlreadyLoaded(ygis []uint) (newYgis []uint)
- type SparseBoolMatrix
- func (sbm *SparseBoolMatrix) CreateRandMat(nbFeat int, refFeats []uint)
- func (sbm *SparseBoolMatrix) GetMatColT() []map[uint]bool
- func (sbm *SparseBoolMatrix) GetUniformSampling(downsample, totXgi int, matColBucket [][]uint) (xgiIndex []uint)
- func (sbm *SparseBoolMatrix) Init(attributes Attributes)
- func (sbm *SparseBoolMatrix) Init2(attributes Attributes)
- func (sbm *SparseBoolMatrix) InitMeta(xgiMap map[string]uint, attributes Attributes, skipFirst bool)
- func (sbm *SparseBoolMatrix) InitTranspose()
- func (sbm *SparseBoolMatrix) LoadClustersFile()
- func (sbm *SparseBoolMatrix) LoadMatrix()
- func (sbm *SparseBoolMatrix) LoadMatrix2(xgiMap, ygiMap map[string]uint)
- type SparseFloatMatrix
Constants ¶
This section is empty.
Variables ¶
var MATRIXFORMATS = [...]Format{coo, mtx, cellRanger}
MATRIXFORMATS possible options for matrix format
Functions ¶
func GetRandomBootstrapIndex ¶
GetRandomBootstrapIndex get a random index with repetition
func LoadIndexFileToIndex ¶
func LoadIndexFileToIndex(fname utils.Filename, downcase bool, refMapping map[string]uint) (celliddict map[string]uint, maxIndex int)
LoadIndexFileToIndex create cell ID index dict. Return also max Index
func LoadPeakDictsToIndex ¶
func LoadPeakDictsToIndex(fname utils.Filename, sepIn, sepOut string) (featiddict map[string]uint, maxIndex int)
LoadPeakDictsToIndex create cell ID index dict
func TestStringToPeak ¶
TestStringToPeak test if string is a valid peak
Types ¶
type Attributes ¶
type Attributes struct { Xgi utils.Filename Ygi utils.Filename MatFile utils.Filename XgiSubset utils.Filename YgiSubset utils.Filename ClustersFile utils.Filename MatrixFormat string NbThreads int }
Attributes matrix attributes pasrsed during init
type MatColFloatHash ¶
type MatColFloatHash struct {
// contains filtered or unexported fields
}
MatColFloatHash matrix column class for sparse float matrix
type MatColHash ¶
type MatColHash struct {
// contains filtered or unexported fields
}
MatColHash matrix column class that can allocate dense submatrices
func (*MatColHash) GetCol ¶
func (mc *MatColHash) GetCol(ygi uint) []bool
GetCol get matrix coloumn in dense bool vector
func (*MatColHash) GetDim ¶
func (mc *MatColHash) GetDim() (xDim, yDim int)
GetDim return dimenssion
func (*MatColHash) GetIndex ¶
func (mc *MatColHash) GetIndex(ygi uint) uint
GetIndex get index from hashed ygi
func (*MatColHash) GetRow ¶
func (mc *MatColHash) GetRow(ygi uint) map[uint]bool
GetRow get row from matCol using a sparse map[uint]bool
func (*MatColHash) GetRowDense ¶
func (mc *MatColHash) GetRowDense(ygi uint) (vect []bool)
GetRowDense return row vector as a dense bool array. If matrix is not sparse, construct the vector
func (*MatColHash) Init ¶
func (mc *MatColHash) Init(matCol *[]map[uint]bool, xDim uint)
Init init MatColHash
func (*MatColHash) InitDense ¶
func (mc *MatColHash) InitDense(matColDense [][]bool)
InitDense init MatColHash with a dense matrix
func (*MatColHash) IsDense ¶
func (mc *MatColHash) IsDense() bool
IsDense return if struct dense is initiated
func (*MatColHash) Len ¶
func (mc *MatColHash) Len(ygiIndex uint) int
Len Return the number of non-zero elements of a columns
func (*MatColHash) ToDenseFromSubset ¶
func (mc *MatColHash) ToDenseFromSubset(ygis []uint) (newYgis []uint)
ToDenseFromSubset sparse to dense
func (*MatColHash) ToDenseFromSubsetAlreadyLoaded ¶
func (mc *MatColHash) ToDenseFromSubsetAlreadyLoaded(ygis []uint) (newYgis []uint)
ToDenseFromSubsetAlreadyLoaded sparse to dense but does not recreate matColDense because already loaded (used when neighborhood == 0)
type SparseBoolMatrix ¶
type SparseBoolMatrix struct {
XgiIndex, YgiIndex []string
XgiIndexC, YgiIndexC map[string]uint
Clusters map[string][]uint // cluster key -> list of cell IDs
Xdim, Ydim int // Dimension of the matrixyDim int // Dimension of the matrix
MatCol MatColHash // mat.Get(posy, posx)
RandMatCol MatColHash // mat[posy][posx] with random posx from
// contains filtered or unexported fields
}
SparseBoolMatrix class
func (*SparseBoolMatrix) CreateRandMat ¶
func (sbm *SparseBoolMatrix) CreateRandMat(nbFeat int, refFeats []uint)
CreateRandMat Create a random matrix of size nbFeat x len(XgiIndex)
func (*SparseBoolMatrix) GetMatColT ¶
func (sbm *SparseBoolMatrix) GetMatColT() []map[uint]bool
GetMatColT Get MatColT
func (*SparseBoolMatrix) GetUniformSampling ¶
func (sbm *SparseBoolMatrix) GetUniformSampling(downsample, totXgi int, matColBucket [][]uint) (xgiIndex []uint)
GetUniformSampling get a uniform sampling of the xgi indexes according to the ygi
func (*SparseBoolMatrix) Init ¶
func (sbm *SparseBoolMatrix) Init(attributes Attributes)
Init Init dedicated to the gene matrix without loading the cluster file. The ygi index is regarded as peak region and the Clusters file is loaded
func (*SparseBoolMatrix) Init2 ¶
func (sbm *SparseBoolMatrix) Init2(attributes Attributes)
Init2 Init dedicated to the gene matrix without loading the cluster file. The ygi index is not regarded as peak region and is loaded with LoadIndexFileToIndex
func (*SparseBoolMatrix) InitMeta ¶
func (sbm *SparseBoolMatrix) InitMeta(xgiMap map[string]uint, attributes Attributes, skipFirst bool)
InitMeta init Metadata matrix, drop first binary attributes
func (*SparseBoolMatrix) InitTranspose ¶
func (sbm *SparseBoolMatrix) InitTranspose()
InitTranspose create a transpose matrix of matCol and instantiate matColBucket
func (*SparseBoolMatrix) LoadClustersFile ¶
func (sbm *SparseBoolMatrix) LoadClustersFile()
LoadClustersFile load cluster file for sparse matrix
func (*SparseBoolMatrix) LoadMatrix ¶
func (sbm *SparseBoolMatrix) LoadMatrix()
LoadMatrix load matrix
func (*SparseBoolMatrix) LoadMatrix2 ¶
func (sbm *SparseBoolMatrix) LoadMatrix2(xgiMap, ygiMap map[string]uint)
LoadMatrix2 load matrix with xgi and ygi Index. If ygiMap is empty, use the default ygi index
type SparseFloatMatrix ¶
type SparseFloatMatrix struct {
XgiIndex, YgiIndex []string
XgiIndexC, YgiIndexC map[string]uint
Xdim, Ydim int // Dimension of the matrixyDim int // Dimension of the matrix
MatCol MatColFloatHash // mat.Get(posy, posx)
// contains filtered or unexported fields
}
SparseFloatMatrix class
func (*SparseFloatMatrix) Init ¶
func (sfm *SparseFloatMatrix) Init(attributes Attributes)
Init Init dedicated to the gene matrix without loading the cluster file. The ygi index is regarded as peak region and the Clusters file is loaded
func (*SparseFloatMatrix) LoadMatrix ¶
func (sfm *SparseFloatMatrix) LoadMatrix(xgiMap, ygiMap map[string]uint)
LoadMatrix load float matrix with xgi and ygi Index. If ygiMap is empty, use the default ygi index