Skip to content

Commit 815575b

Browse files
committed
fix plotLabel bug for j in colData
1 parent fb24054 commit 815575b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

R/plotLabel.R

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,15 @@ setMethod("plotLabel", "SpatialData", \(x, i=1, j=1, k=NULL, c=NULL,
7070
stopifnot(length(c) == 1, is.character(c))
7171
t <- table(x, hasTable(x, i, name=TRUE))
7272
ik <- .instance_key(t)
73+
# TODO: search ik in both internal and regular colData for now
74+
# thus perhaps update, SpatialData::valTable instead
7375
# idx <- match(df$z, int_colData(t)[[ik]])
74-
idx <- match(df$z,
75-
valTable(x, i, ik, assay=assay))
76+
if(ik %in% names(int_colData(t))){
77+
coldata <- int_colData(t)[[ik]]
78+
} else {
79+
coldata <- colData(t)[[ik]]
80+
}
81+
idx <- match(df$z, coldata)
7682
df$z <- valTable(x, i, c, assay=assay)[idx]
7783
if (c == ik) df$z <- factor(df$z)
7884
aes$fill <- aes(.data[["z"]])[[1]]

0 commit comments

Comments
 (0)