Skip to main content
Glama

log1p

Apply log(X+1) transformation to single-cell RNA sequencing data matrices for preprocessing and normalization, enabling downstream analysis.

Instructions

Logarithmize the data matrix (X = log(X + 1))

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
baseNoBase of the logarithm. Natural logarithm is used by default.
chunkedNoProcess the data matrix in chunks, which will save memory.
chunk_sizeNoNumber of observations in the chunks to process the data in.
layerNoEntry of layers to transform.
obsmNoEntry of obsm to transform.

Implementation Reference

  • Generic handler that executes the scanpy pp function (sc.pp.log1p for 'log1p') on the active AnnData object with validated arguments and inplace=True, also logs the operation.
    def run_pp_func(ads, func, arguments):
        adata = ads.adata_dic[ads.active]
        if func not in pp_func:
            raise ValueError(f"不支持的函数: {func}")
        
        run_func = pp_func[func]
        parameters = inspect.signature(run_func).parameters
        arguments["inplace"] = True
        kwargs = {k: arguments.get(k) for k in parameters if k in arguments}
        try:
            res = run_func(adata, **kwargs)
            add_op_log(adata, run_func, kwargs)
        except KeyError as e:
            raise KeyError(f"Can not foud {e} column in adata.obs or adata.var")
        except Exception as e:
           raise e
        return res
  • Pydantic model for input validation of log1p tool parameters: base, chunked, chunk_size, layer, obsm.
    class Log1PModel(JSONParsingModel):
        """Input schema for the log1p preprocessing tool."""
        
        base: Optional[Union[int, float]] = Field(
            default=None,
            description="Base of the logarithm. Natural logarithm is used by default."
        )
        
        chunked: Optional[bool] = Field(
            default=None,
            description="Process the data matrix in chunks, which will save memory."
        )
        
        chunk_size: Optional[int] = Field(
            default=None,
            description="Number of observations in the chunks to process the data in."
        )
        
        layer: Optional[str] = Field(
            default=None,
            description="Entry of layers to transform."
        )
        
        obsm: Optional[str] = Field(
            default=None,
            description="Entry of obsm to transform."
        )
        
        @field_validator('chunk_size')
        def validate_chunk_size(cls, v: Optional[int]) -> Optional[int]:
            """Validate chunk_size is positive integer"""
            if v is not None and v <= 0:
                raise ValueError("chunk_size must be a positive integer")
            return v
  • Registers the 'log1p' tool using mcp.types.Tool with name, description, and reference to Log1PModel schema.
    log1p = types.Tool(
        name="log1p",
        description="Logarithmize the data matrix (X = log(X + 1))",
        inputSchema=Log1PModel.model_json_schema(),
    )
  • Maps 'log1p' tool name to the underlying sc.pp.log1p function used by the handler.
    pp_func = {
        "filter_genes": sc.pp.filter_genes,
        "filter_cells": sc.pp.filter_cells,
        "calculate_qc_metrics": partial(sc.pp.calculate_qc_metrics, inplace=True),
        "log1p": sc.pp.log1p,
        "normalize_total": sc.pp.normalize_total,
        "pca": sc.pp.pca,
        "highly_variable_genes": sc.pp.highly_variable_genes,
        "regress_out": sc.pp.regress_out,
        "scale": sc.pp.scale,
        "combat": sc.pp.combat,
        "scrublet": sc.pp.scrublet,
        "neighbors": sc.pp.neighbors,
    }
  • Adds the log1p Tool object to the pp_tools dictionary, which is used for listing tools in the MCP server.
    pp_tools = {
        "filter_genes": filter_genes,
        "filter_cells": filter_cells,
        "calculate_qc_metrics": calculate_qc_metrics,
        "log1p": log1p,
        "normalize_total": normalize_total,
        "pca": pca,
        "highly_variable_genes": highly_variable_genes,
        "regress_out": regress_out,
        "scale": scale,
        "combat": combat,
        "scrublet": scrublet,
        "neighbors": neighbors,
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It states the transformation but doesn't disclose behavioral traits: whether it modifies data in-place or returns a copy, memory implications (beyond what 'chunked' parameter hints at), error handling for negative values, or typical output format. For a data transformation tool with zero annotation coverage, this leaves significant gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise—a single sentence with the mathematical formula. It's front-loaded with the core purpose and wastes no words. Every part earns its place by precisely defining the transformation.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (data transformation with 5 parameters) and lack of annotations/output schema, the description is incomplete. It doesn't cover behavioral aspects, usage context, or output expectations. For a tool in a bioinformatics preprocessing context with many siblings, more guidance is needed to help an agent use it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents all 5 parameters. The description adds no parameter-specific information beyond implying a data matrix input (not explicitly a parameter). It doesn't explain parameter interactions or provide examples. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the mathematical operation: 'Logarithmize the data matrix (X = log(X + 1))'. It specifies the verb ('logarithmize') and resource ('data matrix'), and the formula clarifies the exact transformation. However, it doesn't differentiate from sibling tools like 'normalize_total' or 'scale', which are also preprocessing operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention typical use cases (e.g., for count data in single-cell analysis), prerequisites, or comparisons to sibling tools like 'normalize_total' or 'scale'. The agent must infer usage from the mathematical formula alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/huang-sh/scmcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server