Skip to main content
Glama

get_differential_expression

Compare gene expression levels between different tissue groups using GTEx data to identify significant differences in biological samples.

Instructions

Get differential gene expression between tissue groups

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
gencodeIdYesGENCODE gene ID (e.g., ENSG00000223972.5)
comparisonGroupsYesArray of tissue groups to compare
datasetIdNoGTEx dataset ID (default: gtex_v8)gtex_v8

Implementation Reference

  • Implements the core logic for get_differential_expression tool: validates inputs, fetches median gene expression data via API client, groups tissues by comparison categories, computes mean expression and fold changes between groups, generates formatted output with statistics.
    async getDifferentialExpression(args: any) {
      if (!args.geneId || typeof args.geneId !== 'string') {
        throw new Error('geneId parameter is required and must be a gene ID');
      }
      
      if (!args.comparisonGroups || !Array.isArray(args.comparisonGroups) || args.comparisonGroups.length < 2) {
        throw new Error('comparisonGroups parameter is required and must contain at least 2 tissue groups');
      }
    
      // Get median expression for the gene
      const result = await this.apiClient.getMedianGeneExpression(
        [args.geneId],
        args.datasetId || 'gtex_v8'
      );
    
      if (result.error) {
        return {
          content: [{
            type: "text",
            text: `Error retrieving differential expression data: ${result.error}`
          }],
          isError: true
        };
      }
    
      const expressions = result.data || [];
      if (expressions.length === 0) {
        return {
          content: [{
            type: "text",
            text: `No expression data found for gene: ${args.geneId}`
          }]
        };
      }
    
      const geneName = expressions[0].geneSymbol;
      
      // Group tissues by comparison groups (simplified - using tissue name matching)
      const groupData: { [group: string]: any[] } = {};
      
      expressions.forEach(expr => {
        const tissueName = expr.tissueSiteDetailId.toLowerCase();
        
        // Simple matching logic for common tissue groups
        for (const group of args.comparisonGroups) {
          const groupLower = group.toLowerCase();
          if (tissueName.includes(groupLower) || 
              (groupLower === 'brain' && tissueName.includes('brain')) ||
              (groupLower === 'heart' && tissueName.includes('heart')) ||
              (groupLower === 'muscle' && tissueName.includes('muscle')) ||
              (groupLower === 'skin' && tissueName.includes('skin'))) {
            
            if (!groupData[group]) {
              groupData[group] = [];
            }
            groupData[group].push(expr);
            break;
          }
        }
      });
    
      let output = `**Differential Expression Analysis**\n`;
      output += `Gene: **${geneName}** (${args.geneId})\n`;
      output += `Dataset: ${expressions[0].datasetId}\n`;
      output += `Comparison Groups: ${args.comparisonGroups.join(' vs ')}\n\n`;
    
      // Show results for each group
      const groupStats: { [group: string]: { mean: number, count: number, tissues: string[] } } = {};
      
      Object.entries(groupData).forEach(([group, groupExpressions]) => {
        if (groupExpressions.length === 0) {
          output += `**${group}**: No matching tissues found\n`;
          return;
        }
    
        const values = groupExpressions.map(e => e.median);
        const mean = values.reduce((sum, val) => sum + val, 0) / values.length;
        const tissues = groupExpressions.map(e => this.getTissueDisplayName(e.tissueSiteDetailId));
        
        groupStats[group] = { mean, count: values.length, tissues };
        
        output += `**${group} (${values.length} tissues)**:\n`;
        output += `  • Mean expression: ${mean.toFixed(3)} TPM\n`;
        output += `  • Range: ${Math.min(...values).toFixed(3)} - ${Math.max(...values).toFixed(3)} TPM\n`;
        output += `  • Tissues: ${tissues.join(', ')}\n\n`;
      });
    
      // Calculate fold changes between groups
      const groups = Object.keys(groupStats);
      if (groups.length >= 2) {
        output += `**Differential Analysis:**\n`;
        for (let i = 0; i < groups.length; i++) {
          for (let j = i + 1; j < groups.length; j++) {
            const group1 = groups[i];
            const group2 = groups[j];
            const foldChange = groupStats[group1].mean / groupStats[group2].mean;
            const logFC = Math.log2(foldChange);
            
            output += `• **${group1} vs ${group2}**:\n`;
            output += `  - Fold change: ${foldChange.toFixed(3)}x\n`;
            output += `  - Log2(FC): ${logFC.toFixed(3)}\n`;
            output += `  - Direction: ${foldChange > 1 ? `Higher in ${group1}` : `Higher in ${group2}`}\n`;
          }
        }
      }
    
      output += `\n**Note**: This is a simplified differential analysis using median values. `;
      output += `Proper differential expression requires statistical testing with sample-level data.\n`;
    
      return {
        content: [{
          type: "text",
          text: output
        }]
      };
    }
  • Defines the tool schema including name, description, and input schema with required parameters gencodeId and comparisonGroups.
    name: "get_differential_expression",
    description: "Get differential gene expression between tissue groups",
    inputSchema: {
      type: "object",
      properties: {
        gencodeId: {
          type: "string",
          description: "GENCODE gene ID (e.g., ENSG00000223972.5)"
        },
        comparisonGroups: {
          type: "array",
          items: { type: "string" },
          description: "Array of tissue groups to compare"
        },
        datasetId: {
          type: "string",
          description: "GTEx dataset ID (default: gtex_v8)",
          default: "gtex_v8" 
        }
      },
      required: ["gencodeId", "comparisonGroups"]
    }
  • src/index.ts:663-669 (registration)
    Registers the tool by dispatching calls to the expressionHandlers.getDifferentialExpression method in the central tool request handler.
    if (name === "get_differential_expression") {
      return await expressionHandlers.getDifferentialExpression({
        gencodeId: args?.gencodeId,
        comparisonGroups: args?.comparisonGroups || [],
        datasetId: args?.datasetId
      });
    }
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 of behavioral disclosure. While 'Get' implies a read operation, it doesn't clarify whether this is computationally intensive, has rate limits, requires specific permissions, or what the output format looks like (e.g., statistical values like p-values, fold changes). For a tool performing differential analysis with no annotation coverage, this is a significant gap.

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 a single, efficient sentence that directly states the tool's purpose without any fluff or redundancy. It's appropriately sized and front-loaded, making it easy to parse quickly.

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 of differential expression analysis (a statistical comparison), no annotations, and no output schema, the description is incomplete. It doesn't address what the tool returns (e.g., log fold changes, p-values), potential limitations, or how to interpret results, leaving significant gaps for an AI agent to use it effectively.

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 already documents all three parameters thoroughly. The description adds no additional meaning beyond what's in the schema—it doesn't explain how 'comparisonGroups' should be formatted (e.g., pairwise comparisons) or provide examples beyond the basic scope. 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 action ('Get differential gene expression') and target resource ('between tissue groups'), which is specific and unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'get_gene_expression' or 'get_median_gene_expression', which also deal with gene expression data but with different analytical purposes.

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. With many sibling tools related to gene expression (e.g., 'get_gene_expression', 'get_median_gene_expression', 'get_clustered_expression'), there's no indication of the specific scenarios where differential expression analysis is preferred over other expression-related queries.

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/Augmented-Nature/GTEx-MCP-Server'

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