scalpelStep3 {scalpel} | R Documentation |
Perform Step 3 of SCALPEL.
Description
This step involves spatial component selection and temporal component estimation. We estimate the temporal components corresponding to the dictionary elements from Step 2 by solving a sparse group lasso problem with a non-negativity constraint.
Usage
scalpelStep3(
step2Output,
lambdaMethod = "trainval",
lambda = NULL,
minClusterSize = 1,
alpha = 0.9,
removeBorder = FALSE,
excludeReps = NULL
)
Arguments
step2Output |
An object of class |
lambdaMethod |
A description of how lambda should be chosen: either |
lambda |
The value of lambda to use when fitting the sparse group lasso. By default, the value is automatically
chosen using the approach specified by |
minClusterSize |
The minimum number of preliminary dictionary elements that a cluster must contain in order to be included in the sparse group lasso. The default value is 1 (i.e., all possible dictionary elements are included). |
alpha |
The value of alpha to use when fitting the sparse group lasso. The default value is 0.9. |
removeBorder |
A logical scalar indicating whether the dictionary elements containing pixels in the 10-pixel
border of the video should be removed prior to fitting the sparse group lasso. The default value is |
excludeReps |
A vector giving the indices of which dictionary elements to exclude, where the indices refer
to the columns of |
Details
To solve the sparse group lasso problem in this step, we minimize the following over Z
with all non-negative elements:
0.5*sum((Y - AfilterTilde %*% Z)^2) + lambda*alpha*sum(Z)
+ lambda*(1-alpha)*sum(sqrt(rowSums(Z^2)))
where AfilterTilde
is a scaled version of Afilter
.
Several files containing data from this step and a summary of the step are saved in the folder
"outputFolder/Step1_version/Step2_omega_omega_cutoff_cutoff/Step3_lambdaMethod_lambdaMethod_
minClusterSize_minClusterSize_alpha_alpha_removeBorder_removeBorder" where version
is a 5-digit unique
identifier that is automatically generated in Step 1, omega
and cutoff
are the user-supplied parameters
from Step 2, and lambdaMethod
, minClusterSize
, alpha
, and removeBorder
are
the user-supplied parameters from this step. If dictionary elements were manually excluded using excludeReps
,
this is appended to the folder name.
Value
An object of class scalpelStep3
, which can be summarized using summary
and used with the plotting functions
plotResults
, plotResultsAllLambda
, plotSpatial
, plotTemporal
, and plotBrightest
.
Afilter
: A matrix containing the filtered dictionary elements, where the ith column ofAfilter
is a vector of 1's and 0's, indicating whether each pixel is contained in the ith filtered dictionary element. Note thatAfilter
is equivalent toA
after removing the components excluded due to being on the border (ifremoveBorder=TRUE
) or having fewer preliminary dictionary elements in their cluster thanminClusterSize
.Zhat
: A matrix containing the estimated temporal components, where the ith row ofZhat
is the estimated calcium trace corresponding to the ith spatial component (i.e., the ith column ofAfilter
).lambda
: The value of lambda used in fitting the sparse group lasso.ZhatList
: A list of matrices containing the estimated temporal components for alternative values oflambda
specified inlambdaSeq
. These can be plotted usingplotResultsAllLambda
.lambdaSeq
: A vector with length equaling the length ofZhatList
, where the ith element indicates the value of lambda corresponding to the temporal components inZhatList[[i]]
.clustersUse
: A vector with length equaling the number of columns ofAfilter
, where the ith element indicates which column ofstep2Output$A
the ith column ofAfilter
equals.Other elements: As specified by the user or returned from a previous step.
See Also
The entire SCALPEL pipeline can be implemented using the scalpel
function. The
other steps in the pipeline can be run using the scalpelStep0
, scalpelStep1
, scalpelStep2
functions.
Results from this step can be summarized using summary
, loaded at a later time using getScalpelStep3
, and plotted using
plotSpatial
, plotTemporal
, plotResults
, and plotBrightest
.
Examples
## Not run:
### many of the functions in this package are interconnected so the
### easiest way to learn to use the package is by working through the vignette,
### which is available at ajpete.com/software
#assumes you have run the example for the "scalpelStep2" function
#run Step 3 of SCALPEL
Step3Out = scalpelStep3(step2Output = Step2Out)
summary(Step3Out)
## End(Not run)