Skip to contents

A lightweight AI assistant grounded in scSidekick's own documentation (rebuilt automatically from your installed copy, so it never quotes a stale function signature). Answers "which function do I need", identifies likely metadata columns from your actual object, and can read a heatmap image to extract gene names or work backward from a saved figure to the function/arguments that likely made it.

Usage

AskSidekick(
  question = NULL,
  seurat_object = NULL,
  image_path = NULL,
  same_dataset = NA,
  models = .sidekick_default_models,
  rebuild_context = FALSE
)

Arguments

question

Character. What you want to ask. Optional when image_path is supplied (a sensible default prompt is used).

seurat_object

A Seurat object, optional. When supplied, its meta.data columns and any PrepObject()-saved colors are given to the assistant as extra context (e.g. for "which column is Age?" or "what colors do I already have?"), and any column/gene names it proposes are checked against the object's real names afterward.

image_path

Character path to an image (PNG/JPEG or PDF), optional. Use this for a screenshot or saved PDF of a figure: the assistant reads off row/column labels, identifies the likely scSidekick function (using the file's path - scSidekick functions often name their own output folders/files distinctively, e.g. RunSCssGSEA()'s "SC ssGSEA <label>" subfolder), and proposes the call to recreate it.

same_dataset

Logical, NA by default. Only matters when image_path + seurat_object are both given: TRUE means the figure was made from THIS exact object, so the assistant should demand an exact metadata-column match rather than settling for an approximate one (many objects have several similar-but-not-identical columns, e.g. Cluster vs. seurat_clusters vs. Assignment). FALSE/NA means the figure may be from elsewhere (a different object, an earlier package version, a collaborator's file), so the assistant gives its best estimate and says so explicitly rather than implying a confirmed match.

models

Character vector of Gemini model names to try, in order. Defaults to a mix of "Flash Lite" and flagship Flash models, since free tier daily quotas (RPD) differ a lot by model and each is a separate quota pool - see https://aistudio.google.com/rate-limit for your account's actual per-model limits, which vary by account. On a 429/503, AskSidekick() automatically tries the next model in this list and says so when it does.

rebuild_context

Logical. Force a rebuild of the cached documentation context before asking, bypassing the normal version-matched cache. Rarely needed - see RebuildSidekickContext(). Default FALSE.

Value

Invisibly, the assistant's reply (also printed).

Details

Requires a free Google Gemini API key: get one at https://aistudio.google.com/apikey, then add a line to ~/.Renviron: GEMINI_API_KEY=your_key_here and restart R.

Each call is independent (no memory of earlier questions) - the free tier's token-per-minute limit gets used up in 1-2 calls if full conversation history were kept, so ask one self-contained question at a time.