Skip to content

Commit

Permalink
Temp fix for setting of feature meta data in SCTransform

remove the …
Browse files Browse the repository at this point in the history
…@meta.features once automatic NA padding is part of [[<- for assay objects
  • Loading branch information
ChristophH committed Apr 10, 2019
1 parent c4f69d6 commit d419e71
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions R/preprocessing.R
Original file line number Diff line number Diff line change
Expand Up @@ -1002,9 +1002,6 @@ SCTransform <- function(
)
}

# output will go into new assay
assay.out <- CreateAssayObject(counts = umi)

if (verbose) {
message('Determine variable features')
}
Expand All @@ -1014,7 +1011,6 @@ SCTransform <- function(
} else {
top.features <- names(x = feature.variance)[feature.variance >= variable.features.rv.th]
}
VariableFeatures(object = assay.out) <- top.features
if (verbose) {
message('Set ', length(x = top.features), ' variable features')
}
Expand All @@ -1033,17 +1029,17 @@ SCTransform <- function(
}
}

# put corrected umi counts in count slot
# create output assay and put (corrected) umi counts in count slot
if (do.correct.umi & residual.type == 'pearson') {
if (verbose) {
message('Place corrected count matrix in counts slot')
}
assay.out <- SetAssayData(
object = assay.out,
slot = 'counts',
new.data = vst.out$umi_corrected
)
assay.out <- CreateAssayObject(counts = vst.out$umi_corrected)
} else {
assay.out <- CreateAssayObject(counts = umi)
}
# set the variable genes
VariableFeatures(object = assay.out) <- top.features

# put log1p transformed counts in data
assay.out <- SetAssayData(
Expand Down Expand Up @@ -1088,7 +1084,8 @@ SCTransform <- function(
vst.out$y <- NULL
assay.out@misc <- list(vst.out = vst.out)
# also put gene attributes in meta.features
assay.out[[names(x = vst.out$gene_attr)]] <- vst.out$gene_attr
#assay.out[[names(x = vst.out$gene_attr)]] <- vst.out$gene_attr # use this when Paul has implemented automatic padding
assay.out@meta.features <- vst.out$gene_attr # hacky workaround to make vignettes compile

object[[new.assay.name]] <- assay.out
if (verbose) {
Expand Down

0 comments on commit d419e71

Please sign in to comment.