-
Notifications
You must be signed in to change notification settings - Fork 81
Using Tags with Data Items
The tagging mechanism within singleCellTK allows setting of tags to all data items including assays, subsets (altExperiments) and reducedDims for easier tracking during manipulation of these data items in downstream analysis. This particularly helps in differentiating between multiple types of data items during an analysis workflow, e.g., all assays processed through normalization (either through UI or console) are tagged as "normalized" and those processed through feature selection are tagged as "hvg" and so on. In the UI, this tagging mechanism allows the developers to populate the selectInput data selection UI elements to populate the data items separated by their tags and further use these data items through a common interface within the processing functions.
- Add tag to an assay (or a subset) at the time of setting that assay (or a subset) using the
expData<-method. If assays are already present in an object, default tag can be set to all assays in the object usingexpSetDataTagmethod (and settingappendparameter toFALSE). - Populate data items
selectInputby specifying the tags against which the assays should be populated in the user-interface using theupdateSelectInputTagfunction. - Retrieve a data item (an assay or a subset (altExp) or a reducedDim) by calling the
expDatamethod.
A summary of the tagging workflow can be better understood from the figure below:
Tags can be set to a data item through either one of the following two ways:
-
Add a tag to an assay when setting that assay to the object by using the
expData<-setter method (instead of theassay<-setter method). The basic usage ofexpData<-method is same asassay<-setter method:
expData(vals$counts, "CPMCounts") <- calculateCPM(assay(vals$counts, “counts”))
By default “uncategorized” tag is set to all assays stored with theexpData<-method call whentagparameter is missing or NULL as in the code snippet given above. To set a tag other than “uncategorized”, specify the tag name in thetagparameter of the method call:
expData(vals$counts, "CPMCounts", tag = "normalized") <- calculateCPM(assay(vals$counts, “counts”))
The same method can also be used to store a subset (as an altExperiment) by specifying thetagparameter and settingaltExpparameter toTRUE:
expData(vals$counts, “subset1”, tag = “hvg”, altExp = TRUE) <- FindHVG() -
Set a tag to a data item manually by using the
expSetDataTagfunction. This function works in two ways based on the value of theappendparameter, which by default is set toTRUE.
UsingexpSetDataTagfunction withappendset toTRUEadds a tag against a new assay that has just been stored:
sce <- expSetDataTag(sce, "raw", "counts", append = TRUE)
The above approach (withappendvalue set toTRUEis not generally recommended, insteadexpData<-method should be used directly while storing a data item to set a tag.
UsingexpSetDataTagfunction withappendset toFALSEoverrides the tag against avector(or acharactervalue) of assay names that correspond to a certain tag:
sce <- expSetDataTag(sce, "raw", assayNames(sce), append = FALSE)
The above function should be used specifically when a data object is uploaded without having tags previously stored.
The selectInputs in the toolkit can be populated with all data items (assays, altExperiments/subsets or reducedDims) by using the appropriate call to the updateSelectInputTag function.
In the UI file:
Create a uiOutput:
uiOutput("dimRedAssaySelect")
In the server file:
Inside the updateAssayInputs function, you can use the following calls to populate the selectInput with the specified data items:
- Populate the
selectInputwith all available assays but do not separate by tags:
updateSelectInputTag(session, "dimRedAssaySelect", choices = currassays)
- Populate the
selectInputwith all available assays and separate by tags:
updateSelectInputTag(session, "dimRedAssaySelect", choices = currassays, showTags = TRUE)
- Populate the
selectInputwith only the assays from a particular tag or a list of tags:
updateSelectInputTag(session, "dimRedAssaySelect", tags = c("raw", "normalized"))
- Populate the
selectInputwith only assays from a particular tag or list of tags and set one of these tags as “recommended”:
updateSelectInputTag(session, "dimRedAssaySelect", tags = c("raw", "normalized"), recommended = "raw")
- By default the “label” for the
selectInputis set to “Select assay:”, but can be changed by passing a value to the “label” parameter:
updateSelectInputTag(session, "dimRedAssaySelect", tags = c("raw", "normalized"), recommended = "raw", label = "Select normalized assay:")
- This method can also be used to populate the reducedDims from the object in the selectInput:
updateSelectInputTag(session, “assaySelect”, tags = c(“raw”, “normalized”), recommended = “normalized”, redDims = TRUE)
-
expSetDataTag: Manually assign a tag to an assay. Theappendparameter in the function (default toTRUE) decides if an assay with a tag should be appended to the existing tags (TRUE) or if all tags should be overridden with the current assignment (FALSE). -
expDataNames: Returns a combinedvectorof all data items including assays, subsets (altExperiments) and reducedDims. -
expData: Returns a data item from the object including assay, subset (altExperiment) or reducedDim based upon the name in theiparameter. Remaining parameters are same asassaymethod. -
expData<-: Store an assay and assign a tag to it but using an additional parametertag. Remaining parameters are same asassay<-method. -
expTaggedData: Returns a list of names of data items from the input object based upon the input parameters, i.e.tagsparameter ensures that names of data items from the specified tags are returned, andredDimsindicates if reducedDims should also be returned in the list. -
expDeleteDataTag: Deletes a tag against a specified assay.
- Store an assay and assign a tag to it in the server file:
expData(sce, "counts", tag = "raw") <- rawMatrix
- Populate the data items in the UI (assuming that UI file has a
uiOutputwith iddimRedAssaySelect) from the server file:
updateSelectInputTag(session, "dimRedAssaySelect", tags = c("raw"), recommended = "raw")
- Inside R functions, use a check to make sure that the data item exists in the object (can be an assay, or a subset/altExperiment or a reducedDim):
if(assayName %in% expDataNames(sce)) stop("Data item does not exist in the input object")
UseexpDatamethod (instead of theassaymethod) to retrieve and use the data:
expData(sce, "normalizedCounts", tag = "normalized") <- someMethod(expData(sce, "counts"))
| Input Id | File |
|---|---|
| dimRedAssaySelect | ui_04_fs_dimred.R |
| dimRedAssaySelect_tsneUmap | ui_04_fs_dimred.R |
| batchCorrAssay | ui_04_batchcorrect.R |
| batchCheckAssay | - |
| batchCheckOrigAssay | ui_04_batchcorrect.R |
| deAssay | ui_05_1_diffex.R |
| fmAssay | ui_05_2_findMarker.R |
| fmHMAssay | server.R |
| pathwayAssay | ui_06_1_pathway.R |
| modifyAssaySelect | ui_04_batchcorrect.R |
| normalizeAssaySelect | ui_04_batchcorrect.R |
| seuratSelectNormalizationAssay | ui_09_2_seuratWorkflow.R |
| assaySelectFS_Norm | ui_04_fs_dimred.R |
| filterAssaySelect | partials.R |
| qcAssaySelect | ui_02_qc.R |
| celdaAssay | ui_celda.R |
| celdaAssayGS | ui_celda.R |
| celdaAssaytSNE | ui_celda.R |
| celdaAssayProbabilityMap | ui_celda.R |
| celdaAssayModuleHeatmap | ui_celda.R |
| depthAssay | ui_07_subsample.R |
| cellsAssay | ui_07_subsample.R |
| snapshotAssay | ui_07_subsample.R |
| exportAssay | ui_export.R |
| hmAssay | ui_08_3_heatmap.R |
| Tab | Methods | Recommended Tag(s) |
|---|---|---|
| QC | all | raw |
| Normalization | all | raw |
| Normalization - Assay Options | log, log1p | raw, normalized |
| Normalization - Assay Options | z.score | normalized |
| Batch Correction | FastMNN, Limma, MNN | normalized |
| Batch Correction | ZINBWaVE, ComBatSeq | raw |
| Batch Correction | BBKNN | scaled |
| Feature Selection | all | normalized, scaled |
| Dimensionality Reduction | all | normalized, scaled |
| Clustering | ||
| Differential Expression | all | normalized, scaled |
| Find Markers | all | normalized, scaled |
| Cell Type Labeling | all | normalized |
| GSVA | all | normalized, scaled |
| EnrichR | ||
| Sample Size Calculator | ||
| Curated Workflows | all | untagged |
Last Updated: March 13, 2021
Open a Github issue and assign to irzamsarfraz or email to irzam9095@gmail.com.
