Fixed bug with running scVI integration over SCTransformed data #184
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As described at the bottom of this issue , when running
IntegrateLaters
over anSCT
assay with thescVIIntegration
method, we get the following error:This error happens when calling
JoinLayers
(line 93). The purpose of this line is to join the different (count) layers so to create a single counts matrix to pass to AnnData (line 98, callingLayerData
). While the call toJoinLayers
is indeed needed for a standard assay (and thusscVIIntegration
works over RNA assay), it is not needed for anSCTAssay
as callingLayerData
with such an assay pulls the information from all nested SCTModels. The proposed solution is therefore to callJoinLayers
only or standard assays:One additional change regards the downstream use of the scVI integrated reduction object. When calling `FindClusters` over an `SCTransform` + `scVIIntegration` + `FindNeighbors` object, it states that there is no graph with the passed name (i.e. by default `"SCT_snn"`). That is because the newly created dimensionality reduction object has an `assay.used` of `"RNA"`. As such the saved graph name is then `"RNA_snn"`, while `FindClusters` is looking for `"SCT_snn"`. To fix that I've:
assay = NULL
as an argument of the function (which is passed fromIntegrateLayers
as SCT (for SCT being the specified assay or the default one)assay = assay
in theCreateDimReducObject
.Code for testing: