Summary
plotMetadata() currently falls back to plotting sample names and RNA cluster columns when metadata.to.plot is blank or resolves to an empty vector. This can hide invalid or cleared user selections because the function still produces plots instead of stopping.
Current behavior
In R/Plot_Metadata.R, after metadata names are normalized and Barcode is removed, an empty selection triggers this fallback:
if (length(m) == 0) {
print("No metadata columns specified.
Plotting sample names and RNA clusters...")
x = colnames(object.sub@meta.data)
x = x[grepl("RNA", x)]
m = c("sample_name", x)
}
As a result, metadata.to.plot = "" can still produce plots, often appearing like a default to sample/orig.ident-style metadata.
Desired behavior
plotMetadata() should error when metadata.to.plot is blank, empty, or contains no valid metadata columns after normalization/filtering. The error should tell the user that at least one metadata column is required and should print/list the available metadata columns.
Suggested acceptance criteria
plotMetadata(..., metadata.to.plot = "") errors before plotting.
plotMetadata(..., metadata.to.plot = character()) errors before plotting.
- The error includes available metadata column names.
- Valid explicit selections continue to work, including metadata names containing dots such as
SCT_snn_res.2.4.
Summary
plotMetadata()currently falls back to plotting sample names and RNA cluster columns whenmetadata.to.plotis blank or resolves to an empty vector. This can hide invalid or cleared user selections because the function still produces plots instead of stopping.Current behavior
In
R/Plot_Metadata.R, after metadata names are normalized andBarcodeis removed, an empty selection triggers this fallback:As a result,
metadata.to.plot = ""can still produce plots, often appearing like a default to sample/orig.ident-style metadata.Desired behavior
plotMetadata()should error whenmetadata.to.plotis blank, empty, or contains no valid metadata columns after normalization/filtering. The error should tell the user that at least one metadata column is required and should print/list the available metadata columns.Suggested acceptance criteria
plotMetadata(..., metadata.to.plot = "")errors before plotting.plotMetadata(..., metadata.to.plot = character())errors before plotting.SCT_snn_res.2.4.