Skip to content

plotMetadata should error when metadata.to.plot is blank #93

Description

@phoman14

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions