Functions
Input
GigaSOM.readFlowset
— MethodreadFlowset(filenames)
Create a dictionary with filenames as keys and daFrame as values
Arguments:
filenames
: Array of type string
Process
GigaSOM.cleanNames!
— MethodcleanNames!(mydata)
Replaces problematic characters in column names. Checks if the column name contains a '-' and transforms it to and '_' and it checks if the name starts with a number.
Arguments:
mydata
: dict fcsRaw or array of string
GigaSOM.createDaFrame
— MethodcreateDaFrame(fcsRaw, md, panel)
Creates a daFrame of type struct. Read in the fcs raw, add sample id, subset the columns and transform
Arguments:
fcsRaw
: raw FCS datamd
: Metadata tablepanel
: Panel table with a column for Lineage Markers and one for Functional Markersmethod
: transformation method, default arcsinh, optionalcofactor
: Cofactor for transformation, default 5, optionalreduce
: Selected only columns which are defined by lineage and functional, optional, default: true. If false the check for any none columns to be removed (none columns can appear after concatenating FCS files as well as parameter like: time, event length)sort
: Sort columns by name to make sure the order when concatinating the dataframes, optional, default: true
GigaSOM.getMarkers
— MethodgetMarkers(panel)
Returns the lineageMarkers
and functionalMarkers
on a given panel
Arguments:
panel
: Panel table with a column for Lineage Markers and one for Functional Markers
GigaSOM.getMetaData
— MethodgetMetaData(f)
Collect the meta data information in a more user friendly format.
Arguments:
f
: input structure with.params
and.data
fields
GigaSOM.sortReduce
— MethodsortReduce(df, cc, reduce, sort)
Sorts the columns and/or reduces them to sleected markers
Arguments:
df
: FCS dataframecc
: Columns to reduce toreduce
: Booleansort
: Boolean
GigaSOM.transformData
— MethodtransformData(flowframe, method, cofactor)
Tansforms FCS data. Currently only asinh
Arguments:
flowframe
: Flowframe containing daFrame per samplemethod
: transformation methodcofactor
: Cofactor for transformation
Core
GigaSOM.expRadius
— FunctionexpRadius(steepness::Float64)
Return a function to be used as a radiusFun
of trainGigaSOM
, which causes exponencial decay with the selected steepness.
Use: trainGigaSOM(..., radiusFun = expRadius(0.5))
Arguments
steepness
: Steepness of exponential descent. Good values range from -100.0 (almost linear) to 100.0 (really quick decay).
GigaSOM.initGigaSOM
— Function initGigaSOM(train, xdim, ydim = xdim; norm = :none, toroidal = false)
Initialises a SOM.
Arguments:
train
: training dataxdim, ydim
: geometry of the SOM If DataFrame, the column names will be used as attribute names. Codebook vectors will be sampled from the training data.norm
: optional normalisation; one of :minmax, :zscore or :none
toroidal
: optional flag; if true, the SOM is toroidal.
GigaSOM.linearRadius
— MethodlinearRadius(initRadius::Float64, iteration::Int64, decay::String, epochs::Int64)
Return a neighbourhood radius. Use as the radiusFun
parameter for trainGigaSOM
.
Arguments
initRadius
: Initial RadiusfinalRadius
: Final Radiusiteration
: Training iterationepochs
: Total number of epochs
GigaSOM.mapToGigaSOM
— MethodmapToGigaSOM(som::Som, data)
Return a DataFrame with X-, Y-indices and index of winner neuron for every row in data.
Arguments
som
: a trained SOMdata
: Array or DataFrame with training data.knnTreeFun
: Constructor of the KNN-tree (e.g. from NearestNeighbors package)metric
: Passed as metric argument to the KNN-tree constructor
Data must have the same number of dimensions as the training dataset and will be normalised with the same parameters.
GigaSOM.trainGigaSOM
— MethodtrainGigaSOM(som::Som, train::DataFrame, kernelFun = gaussianKernel,
r = 0.0, epochs = 10)
Arguments:
som
: object of type Som with an initialised somtrain
: training datakernel::function
: optional distance kernel; one of (bubbleKernel, gaussianKernel
) default isgaussianKernel
rStart
: optional training radius. If r is not specified, it defaults to (xdim+ydim)/3rFinal
: target radius at the last epoch, defaults to 0.1knnTreeFun
: Constructor of the KNN-tree (e.g. from NearestNeighbors package)metric
: Passed as metric argument to the KNN-tree constructorradiusFun
: Function that generates radius decay, e.g.linearRadius
orexpRadius(10.0)
epochs
: number of SOM training iterations (default 10)
Training data must be convertable to Array{Float34,2} with convert()
. Training samples are row-wise; one sample per row. An alternative kernel function can be provided to modify the distance-dependent training. The function must fit to the signature fun(x, r) where x is an arbitrary distance and r is a parameter controlling the function and the return value is between 0.0 and 1.0.
GigaSOM.doEpoch
— MethoddoEpoch(x::Array{Float64}, codes::Array{Float64}, tree)
vectors and the adjustment in radius after each epoch.
Arguments:
x
: training Datacodes
: Codebooktree
: knn-compatible tree built upon the codes
GigaSOM.scaleEpochTime
— MethodscaleEpochTime(iteration::Int64, epochs::Int64)
Convert iteration ID and epoch number to relative time in training.
Structs
GigaSOM.daFrame
— TypedaFrame
Structure to hold FCS files.
Fields:
fcstable::Dict
: Key: Filename, Value: FCS data tablemd::DataFrame
: Metadata containing the filenames, and experiment conditionspanel::DataFrame
: defines which markers to use (lineage, functional)
GigaSOM.Som
— TypeSom
Structure to hold all data of a trained SOM.
Fields:
codes::Array{Float64,2}
: 2D-array of codebook vectors. One vector per rowcolNames::Array{String,1}
: names of the attribute with which the SOM is trainednormParams::DataFrame
: normalisation parameters for each column of training data. Column headers corresponds with colNames.norm::Symbol
: normalisation type; one of:none, :minmax, :zscore
xdim::Int
: number of neurons in x-directionydim::Int
: number of neurons in y-directionnumCodes::Int
: total number of neuronsgrid::Array{Float64,2}
: 2D-array of coordinates of neurons on the map (2 columns (x,y)] for rectangular and hexagonal maps 3 columns (x,y,z) for spherical maps)indices::DataFrame
: X-, Y-indices of the neuronstopol::Symbol
: topology of the SOM; one of:rectangular, :hexagonal, :spherical
toroidal::Bool
: iftrue
, the SOM is toroidal (has no edges)population::Array{Int,1}
: 1D-array of numbers of training samples mapped to each neuron.
Satellites
GigaSOM.checkDir
— MethodcheckDir()
Checks if the pwd()
is the /test
directory, and if not it changes to it.
GigaSOM.convertTrainingData
— MethodconvertTrainingData(data)::Array{Float64,2}
Converts the training data to an Array of type Float64.
Arguments:
data
: Data to be converted
GigaSOM.distMatrix
— MethoddistMatrix(grid::Array, toroidal::Bool)::Array{Float64, 2}
Return the distance matrix for a non-toroidal or toroidal SOM.
Arguments
grid
: coordinates of all neurons as generated by one of thegrid-
functions
with x-coordinates in 1st column and y-coordinates in 2nd column.
toroidal
: true for a toroidal SOM.
GigaSOM.gaussianKernel
— MethodgaussianKernel(x, r::Float64)
Return Gaussian(x) for μ=0.0 and σ = r/3. (a value of σ = r/3 makes the training results comparable between different kernels for same values of r).
Arguments
GigaSOM.gridRectangular
— MethodgridRectangular(xdim, ydim)
Create coordinates of all neurons on a rectangular SOM.
The return-value is an array of size (Number-of-neurons, 2) with x- and y- coordinates of the neurons in the first and second column respectively. The distance between neighbours is 1.0. The point of origin is bottom-left. The first neuron sits at (0,0).
Arguments
xdim
: number of neurons in x-directionydim
: number of neurons in y-direction
GigaSOM.normTrainData
— MethodnormTrainData(train::Array{Float64, 2}, norm::Symbol)
Normalise every column of training data.
Arguments
train
: DataFrame with training Datanorm
: type of normalisation; one ofminmax, zscore, none