Skip to content

Commit ef07a34

Browse files
committed
Add back check.matrix
1 parent 144421c commit ef07a34

File tree

5 files changed

+33
-112
lines changed

5 files changed

+33
-112
lines changed

R/clustering.R

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,7 @@ PredictAssay <- function(
259259
)
260260
colnames(x = predicted) <- Cells(x = object)
261261
if (return.assay) {
262-
# TODO: restore once check.matrix is implemented in SeuratObject
263-
# predicted.assay <- CreateAssayObject(data = predicted, check.matrix = FALSE)
264-
predicted.assay <- CreateAssayObject(data = predicted)
262+
predicted.assay <- CreateAssayObject(data = predicted, check.matrix = FALSE)
265263
return (predicted.assay)
266264
} else {
267265
return (predicted)

R/integration.R

Lines changed: 18 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,19 +1461,12 @@ IntegrateData <- function(
14611461
} else {
14621462
active.assay <- DefaultAssay(object = ref[[1]])
14631463
reference.integrated[[active.assay]] <- NULL
1464-
# TODO: restore once check.matrix is in SeuratObject
1465-
# reference.integrated[[active.assay]] <- CreateAssayObject(
1466-
# data = GetAssayData(
1467-
# object = reference.integrated[[new.assay.name]],
1468-
# slot = 'data'
1469-
# ),
1470-
# check.matrix = FALSE
1471-
# )
14721464
reference.integrated[[active.assay]] <- CreateAssayObject(
14731465
data = GetAssayData(
14741466
object = reference.integrated[[new.assay.name]],
14751467
slot = 'data'
1476-
)
1468+
),
1469+
check.matrix = FALSE
14771470
)
14781471
DefaultAssay(object = reference.integrated) <- active.assay
14791472
reference.integrated[[new.assay.name]] <- NULL
@@ -1496,13 +1489,9 @@ IntegrateData <- function(
14961489
)
14971490

14981491
# Construct final assay object
1499-
# TODO: restore once check.matrix is in SeuratObject
1500-
# integrated.assay <- CreateAssayObject(
1501-
# data = integrated.data,
1502-
# check.matrix = FALSE
1503-
# )
15041492
integrated.assay <- CreateAssayObject(
1505-
data = integrated.data
1493+
data = integrated.data,
1494+
check.matrix = FALSE
15061495
)
15071496
if (normalization.method == "SCT") {
15081497
integrated.assay <- CreateSCTAssayObject(
@@ -1594,13 +1583,9 @@ IntegrateEmbeddings.IntegrationAnchorSet <- function(
15941583
embeddings <- t(x = Embeddings(object = reductions)[cell.names.map[Cells(x = object.list[[i]])], dims.to.integrate])
15951584
rownames(x = embeddings) <- dims.names
15961585
fake.assay <- suppressWarnings(
1597-
# TODO: restore once check.matrix is in SeuratObject
1598-
# expr = CreateAssayObject(
1599-
# data = embeddings,
1600-
# check.matrix = FALSE
1601-
# )
16021586
expr = CreateAssayObject(
1603-
data = embeddings
1587+
data = embeddings,
1588+
check.matrix = FALSE
16041589
)
16051590
)
16061591
object.list[[i]][['drtointegrate']] <- fake.assay
@@ -1636,18 +1621,11 @@ IntegrateEmbeddings.IntegrationAnchorSet <- function(
16361621
}
16371622
active.assay <- DefaultAssay(object = object.list[reference.datasets][[1]])
16381623
reference.integrated[[active.assay]] <- NULL
1639-
# TODO: restore once check.matrix is in SeuratObject
1640-
# reference.integrated[[active.assay]] <- CreateAssayObject(
1641-
# data = GetAssayData(
1642-
# object = reference.integrated[[new.reduction.name.safe]],
1643-
# slot = 'data',
1644-
# check.matrix = FALSE
1645-
# )
1646-
# )
16471624
reference.integrated[[active.assay]] <- CreateAssayObject(
16481625
data = GetAssayData(
16491626
object = reference.integrated[[new.reduction.name.safe]],
1650-
slot = 'data'
1627+
slot = 'data',
1628+
check.matrix = FALSE
16511629
)
16521630
)
16531631
DefaultAssay(object = reference.integrated) <- active.assay
@@ -1734,13 +1712,9 @@ IntegrateEmbeddings.TransferAnchorSet <- function(
17341712
)[ , dims.to.integrate])
17351713
rownames(x = embeddings) <- dims.names
17361714
fake.assay <- suppressWarnings(
1737-
# TODO restore once check.matrix is in SeuratObject
1738-
# expr = CreateAssayObject(
1739-
# data = embeddings,
1740-
# check.matrix = FALSE
1741-
# )
17421715
expr = CreateAssayObject(
1743-
data = embeddings
1716+
data = embeddings,
1717+
check.matrix = FALSE
17441718
)
17451719
)
17461720
object.list[[i]][['drtointegrate']] <- fake.assay
@@ -3014,9 +2988,9 @@ TransferData <- function(
30142988
stringsAsFactors = FALSE
30152989
)
30162990
if (prediction.assay || !is.null(x = query)) {
3017-
# TODO: restore once check.matrix is in SeuratObject
3018-
# predictions <- CreateAssayObject(data = t(x = as.matrix(x = prediction.scores)), check.matrix = FALSE)
3019-
predictions <- CreateAssayObject(data = t(x = as.matrix(x = prediction.scores)))
2991+
predictions <- CreateAssayObject(
2992+
data = t(x = as.matrix(x = prediction.scores)), check.matrix = FALSE
2993+
)
30202994
Key(object = predictions) <- paste0("predictionscore", rd.name, "_")
30212995
}
30222996
if (is.null(x = query)) {
@@ -3040,13 +3014,9 @@ TransferData <- function(
30403014
new.data <- as.sparse(x = new.data)
30413015
}
30423016
if (slot == "counts") {
3043-
# TODO: restore once check.matrix is in SeuratObject
3044-
# new.assay <- CreateAssayObject(counts = new.data, check.matrix = FALSE)
3045-
new.assay <- CreateAssayObject(counts = new.data)
3017+
new.assay <- CreateAssayObject(counts = new.data, check.matrix = FALSE)
30463018
} else if (slot == "data") {
3047-
# TODO: restore once check.matrix is in SeuratObject
3048-
# new.assay <- CreateAssayObject(data = new.data, check.matrix = FALSE)
3049-
new.assay <- CreateAssayObject(data = new.data)
3019+
new.assay <- CreateAssayObject(data = new.data, check.matrix = FALSE)
30503020
}
30513021
Key(object = new.assay) <- paste0(rd.name, "_")
30523022
if (is.null(x = query)) {
@@ -4096,13 +4066,9 @@ PairwiseIntegrateReference <- function(
40964066
features.to.integrate <- features.to.integrate %||% features
40974067
if (length(x = reference.objects) == 1) {
40984068
ref.obj <- object.list[[reference.objects]]
4099-
# TODO: restore once check.matrix is in SeuratObject
4100-
# ref.obj[[new.assay.name]] <- CreateAssayObject(
4101-
# data = GetAssayData(ref.obj, slot = 'data')[features.to.integrate, ],
4102-
# check.matrix = FALSE
4103-
# )
41044069
ref.obj[[new.assay.name]] <- CreateAssayObject(
4105-
data = GetAssayData(ref.obj, slot = 'data')[features.to.integrate, ]
4070+
data = GetAssayData(ref.obj, slot = 'data')[features.to.integrate, ],
4071+
check.matrix = FALSE
41064072
)
41074073
DefaultAssay(object = ref.obj) <- new.assay.name
41084074
return(ref.obj)
@@ -4225,9 +4191,7 @@ PairwiseIntegrateReference <- function(
42254191
verbose = verbose
42264192
)
42274193
integrated.matrix <- cbind(integrated.matrix, GetAssayData(object = object.1, slot = 'data')[features.to.integrate, ])
4228-
# TODO: restore once check.matrix is in SeuratObject
4229-
# merged.obj[[new.assay.name]] <- CreateAssayObject(data = integrated.matrix, check.matrix = FALSE)
4230-
merged.obj[[new.assay.name]] <- CreateAssayObject(data = integrated.matrix)
4194+
merged.obj[[new.assay.name]] <- CreateAssayObject(data = integrated.matrix, check.matrix = FALSE)
42314195
DefaultAssay(object = merged.obj) <- new.assay.name
42324196
object.list[[as.character(x = ii)]] <- merged.obj
42334197
object.list[[merge.pair[[1]]]] <- NULL

R/mixscape.R

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -106,17 +106,11 @@ CalcPerturbSig <- function(
106106
slot(object = object, name = "tools")[[paste("CalcPerturbSig", assay, reduction, sep = ".")]] <- all_neighbors
107107
all_diff <- do.call(what = cbind, args = all_diff)
108108
prtb.assay <- suppressWarnings(
109-
# TODO: restore once check.matrix is in SeuratObject
110-
# expr = CreateAssayObject(
111-
# data = all_diff[, colnames(x = object)],
112-
# min.cells = -Inf,
113-
# min.features = -Inf,
114-
# check.matrix = FALSE
115-
# )
116109
expr = CreateAssayObject(
117110
data = all_diff[, colnames(x = object)],
118111
min.cells = -Inf,
119-
min.features = -Inf
112+
min.features = -Inf,
113+
check.matrix = FALSE
120114
)
121115
)
122116
object[[new.assay.name]] <- prtb.assay
@@ -1028,7 +1022,7 @@ PlotPerturbScore <- function(
10281022
gd <- setdiff(x = unique(x = prtb_score[, target.gene.class]), y = target.gene.ident)
10291023
colnames(x = prtb_score)[2] <- "gene"
10301024
prtb_score$cell.bc <- sapply(rownames(prtb_score), FUN = function(x) substring(x, regexpr("[.]", x) + 1))
1031-
1025+
10321026
if (isTRUE(x = before.mixscape)) {
10331027
cols <- setNames(
10341028
object = c("grey49", col),
@@ -1217,23 +1211,14 @@ GetMissingPerturb <- function(object, assay, features, verbose = TRUE) {
12171211
}
12181212
all_diff <- do.call(what = cbind, args = all_diff)
12191213
all_diff <- all_diff[, colnames(x = object[[assay]]), drop = FALSE]
1220-
# TODO: restore once check.matrix is in SeuratObject
1221-
# new.assay <- CreateAssayObject(
1222-
# data = rbind(
1223-
# GetAssayData(object = object[[assay]], slot = "data"),
1224-
# all_diff
1225-
# ),
1226-
# min.cells = 0,
1227-
# min.features = 0,
1228-
# check.matrix = FALSE
1229-
# )
12301214
new.assay <- CreateAssayObject(
12311215
data = rbind(
12321216
GetAssayData(object = object[[assay]], slot = "data"),
12331217
all_diff
12341218
),
12351219
min.cells = 0,
1236-
min.features = 0
1220+
min.features = 0,
1221+
check.matrix = FALSE
12371222
)
12381223
new.assay <- SetAssayData(
12391224
object = new.assay,

R/preprocessing.R

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,14 +1790,10 @@ SCTransform <- function(
17901790
if (verbose) {
17911791
message('Place corrected count matrix in counts slot')
17921792
}
1793-
# TODO: restore once check.matrix is in SeuratObject
1794-
# assay.out <- CreateAssayObject(counts = vst.out$umi_corrected, check.matrix = FALSE)
1795-
assay.out <- CreateAssayObject(counts = vst.out$umi_corrected,)
1793+
assay.out <- CreateAssayObject(counts = vst.out$umi_corrected, check.matrix = FALSE)
17961794
vst.out$umi_corrected <- NULL
17971795
} else {
1798-
# TODO: restore once check.matrix is in SeuratObject
1799-
# assay.out <- CreateAssayObject(counts = umi, check.matrix = FALSE)
1800-
assay.out <- CreateAssayObject(counts = umi)
1796+
assay.out <- CreateAssayObject(counts = umi, check.matrix = FALSE)
18011797
}
18021798
# set the variable genes
18031799
VariableFeatures(object = assay.out) <- residual.features %||% top.features

R/utilities.R

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,18 +1339,11 @@ PseudobulkExpression <- function(
13391339
if (slot[1] == 'scale.data') {
13401340
na.matrix <- data.return[[1]]
13411341
na.matrix[1:length(x = na.matrix)] <- NA
1342-
# TODO: restore once check.matrix is in SeuratObject
1343-
# toRet <- CreateSeuratObject(
1344-
# counts = na.matrix,
1345-
# project = if (pb.method == "average") "Average" else "Aggregate",
1346-
# assay = names(x = data.return)[1],
1347-
# check.matrix = FALSE,
1348-
# ...
1349-
# )
13501342
toRet <- CreateSeuratObject(
13511343
counts = na.matrix,
13521344
project = if (pb.method == "average") "Average" else "Aggregate",
13531345
assay = names(x = data.return)[1],
1346+
check.matrix = FALSE,
13541347
...
13551348
)
13561349
toRet <- SetAssayData(
@@ -1372,18 +1365,11 @@ PseudobulkExpression <- function(
13721365
new.data = data.return[[1]]
13731366
)
13741367
} else {
1375-
# TODO: restore once check.matrix is in SeuratObject
1376-
# toRet <- CreateSeuratObject(
1377-
# counts = data.return[[1]],
1378-
# project = if (pb.method == "average") "Average" else "Aggregate",
1379-
# assay = names(x = data.return)[1],
1380-
# check.matrix = FALSE,
1381-
# ...
1382-
# )
13831368
toRet <- CreateSeuratObject(
13841369
counts = data.return[[1]],
13851370
project = if (pb.method == "average") "Average" else "Aggregate",
13861371
assay = names(x = data.return)[1],
1372+
check.matrix = FALSE,
13871373
...
13881374
)
13891375
toRet <- SetAssayData(
@@ -1399,9 +1385,7 @@ PseudobulkExpression <- function(
13991385
if (slot[i] == 'scale.data') {
14001386
na.matrix <- data.return[[i]]
14011387
na.matrix[1:length(x = na.matrix)] <- NA
1402-
# TODO: restore once check.matrix is in SeuratObject
1403-
# toRet[[names(x = data.return)[i]]] <- CreateAssayObject(counts = na.matrix, check.matrix = FALSE)
1404-
toRet[[names(x = data.return)[i]]] <- CreateAssayObject(counts = na.matrix)
1388+
toRet[[names(x = data.return)[i]]] <- CreateAssayObject(counts = na.matrix, check.matrix = FALSE)
14051389
toRet <- SetAssayData(
14061390
object = toRet,
14071391
assay = names(x = data.return)[i],
@@ -1421,9 +1405,7 @@ PseudobulkExpression <- function(
14211405
new.data = as.matrix(x = data.return[[i]])
14221406
)
14231407
} else {
1424-
# TODO: restore once check.matrix is in SeuratObject
1425-
# toRet[[names(x = data.return)[i]]] <- CreateAssayObject(counts = data.return[[i]], check.matrix = FALSE)
1426-
toRet[[names(x = data.return)[i]]] <- CreateAssayObject(counts = data.return[[i]])
1408+
toRet[[names(x = data.return)[i]]] <- CreateAssayObject(counts = data.return[[i]], check.matrix = FALSE)
14271409
toRet <- SetAssayData(
14281410
object = toRet,
14291411
assay = names(x = data.return)[i],
@@ -1897,13 +1879,9 @@ CreateDummyAssay <- function(assay) {
18971879
cm <- as.sparse(x = cm)
18981880
rownames(x = cm) <- rownames(x = assay)
18991881
colnames(x = cm) <- colnames(x = assay)
1900-
# TODO: restore once check.matrix is in SeuratObject
1901-
# return(CreateAssayObject(
1902-
# counts = cm,
1903-
# check.matrix = FALSE
1904-
# ))
19051882
return(CreateAssayObject(
1906-
counts = cm
1883+
counts = cm,
1884+
check.matrix = FALSE
19071885
))
19081886
}
19091887

@@ -2336,7 +2314,7 @@ RowSumSparse <- function(mat) {
23362314
names(x = output) <- rownames(x = mat)
23372315
return(output)
23382316
}
2339-
2317+
23402318
# Calculate row variance of a sparse matrix
23412319
#
23422320
# @param mat sparse matrix

0 commit comments

Comments
 (0)