Skip to main content
Glama

get_clustered_expression

Retrieve clustered gene expression data from GTEx to visualize patterns across tissues for specified genes.

Instructions

Get clustered gene expression data for visualization

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
gencodeIdsYesArray of GENCODE gene IDs
datasetIdNoGTEx dataset ID (default: gtex_v8)gtex_v8

Implementation Reference

  • Core handler function that validates geneIds input (max 20), fetches median gene expression data using GTExApiClient, groups expressions by gene, generates summary statistics and tissue ranges for each gene, and formats output as text suitable for clustering visualization and matrix analysis.
    async getClusteredExpression(args: any) {
      if (!args.geneIds || !Array.isArray(args.geneIds) || args.geneIds.length === 0) {
        throw new Error('geneIds parameter is required and must be a non-empty array of gene IDs');
      }
    
      if (args.geneIds.length > 20) {
        return {
          content: [{
            type: "text",
            text: "Maximum 20 genes can be processed for clustering analysis."
          }]
        };
      }
    
      // Get median expression for all genes
      const result = await this.apiClient.getMedianGeneExpression(
        args.geneIds,
        args.datasetId || 'gtex_v8'
      );
    
      if (result.error) {
        return {
          content: [{
            type: "text",
            text: `Error retrieving clustered expression data: ${result.error}`
          }],
          isError: true
        };
      }
    
      const expressions = result.data || [];
      if (expressions.length === 0) {
        return {
          content: [{
            type: "text",
            text: "No expression data found for clustering analysis."
          }]
        };
      }
    
      // Organize data for clustering visualization
      const geneGroups: { [key: string]: any[] } = {};
      expressions.forEach(expr => {
        const key = `${expr.geneSymbol} (${expr.gencodeId})`;
        if (!geneGroups[key]) {
          geneGroups[key] = [];
        }
        geneGroups[key].push(expr);
      });
    
      let output = `**Clustered Gene Expression Analysis**\n`;
      output += `Genes: ${Object.keys(geneGroups).length}\n`;
      output += `Dataset: ${expressions[0]?.datasetId}\n`;
      output += `Format: Median expression values for clustering\n\n`;
    
      // Create expression matrix summary
      output += `**Expression Matrix Summary:**\n`;
      Object.entries(geneGroups).forEach(([geneKey, geneExpressions]) => {
        const sortedExpr = geneExpressions.sort((a, b) => b.median - a.median);
        const stats = {
          max: Math.max(...sortedExpr.map(e => e.median)),
          min: Math.min(...sortedExpr.map(e => e.median)),
          tissues: sortedExpr.length
        };
        
        output += `• **${geneKey}**:\n`;
        output += `  - Tissues: ${stats.tissues}\n`;
        output += `  - Range: ${stats.min.toFixed(3)} - ${stats.max.toFixed(3)} TPM\n`;
        output += `  - Top tissue: ${this.getTissueDisplayName(sortedExpr[0].tissueSiteDetailId)} (${sortedExpr[0].median.toFixed(3)})\n`;
      });
    
      output += `\n**Clustering Notes:**\n`;
      output += `- Expression values are median TPM across samples\n`;
      output += `- Data suitable for hierarchical clustering or PCA analysis\n`;
      output += `- Consider log-transformation for clustering algorithms\n`;
    
      return {
        content: [{
          type: "text",
          text: output
        }]
      };
    }
  • Tool schema definition including name, description, and inputSchema specifying required gencodeIds array and optional datasetId.
    name: "get_clustered_expression",
    description: "Get clustered gene expression data for visualization",
    inputSchema: {
      type: "object",
      properties: {
        gencodeIds: {
          type: "array",
          items: { type: "string" },
          description: "Array of GENCODE gene IDs"
        },
        datasetId: {
          type: "string",
          description: "GTEx dataset ID (default: gtex_v8)",
          default: "gtex_v8"
        }
      },
      required: ["gencodeIds"]
    }
  • src/index.ts:651-656 (registration)
    Tool registration in the main CallToolRequestHandler: routes 'get_clustered_expression' calls to expressionHandlers.getClusteredExpression, mapping input arguments appropriately.
    if (name === "get_clustered_expression") {
      return await expressionHandlers.getClusteredExpression({
        gencodeIds: args?.gencodeIds || [],
        datasetId: args?.datasetId
      });
    }
  • src/index.ts:50-614 (registration)
    Includes the get_clustered_expression tool in the ListToolsRequestHandler response for tool discovery.
    return {
      tools: [
        // Expression Analysis Tools (7 tools)
        {
          name: "get_gene_expression",
          description: "Get gene expression data across tissues for a specific gene",
          inputSchema: {
            type: "object",
            properties: {
              gencodeId: {
                type: "string",
                description: "GENCODE gene ID (e.g., ENSG00000223972.5)"
              },
              datasetId: {
                type: "string", 
                description: "GTEx dataset ID (default: gtex_v8)",
                default: "gtex_v8"
              }
            },
            required: ["gencodeId"]
          }
        },
        {
          name: "get_median_gene_expression",
          description: "Get median gene expression levels across tissues",
          inputSchema: {
            type: "object",
            properties: {
              gencodeId: {
                type: "string",
                description: "GENCODE gene ID (e.g., ENSG00000223972.5)"
              },
              datasetId: {
                type: "string",
                description: "GTEx dataset ID (default: gtex_v8)",
                default: "gtex_v8"
              }
            },
            required: ["gencodeId"]
          }
        },
        {
          name: "get_top_expressed_genes",
          description: "Get top expressed genes in a specific tissue",
          inputSchema: {
            type: "object",
            properties: {
              tissueSiteDetailId: {
                type: "string", 
                description: "Tissue site detail ID (e.g., Muscle_Skeletal, Brain_Cortex)"
              },
              filterMtGenes: {
                type: "boolean",
                description: "Filter out mitochondrial genes (default: true)",
                default: true
              },
              sortBy: {
                type: "string",
                description: "Sort criteria (default: median)",
                enum: ["median", "mean"],
                default: "median"
              },
              sortDirection: {
                type: "string",
                description: "Sort direction (default: desc)",
                enum: ["asc", "desc"], 
                default: "desc"
              },
              datasetId: {
                type: "string",
                description: "GTEx dataset ID (default: gtex_v8)",
                default: "gtex_v8"
              }
            },
            required: ["tissueSiteDetailId"]
          }
        },
        {
          name: "get_tissue_specific_genes",
          description: "Get genes with tissue-specific expression patterns",
          inputSchema: {
            type: "object",
            properties: {
              tissueSiteDetailId: {
                type: "string",
                description: "Tissue site detail ID (e.g., Muscle_Skeletal, Brain_Cortex)"
              },
              selectionCriteria: {
                type: "string",
                description: "Selection criteria for tissue specificity (default: highestInGroup)",
                enum: ["highestInGroup", "aboveThreshold"],
                default: "highestInGroup"
              },
              datasetId: {
                type: "string",
                description: "GTEx dataset ID (default: gtex_v8)", 
                default: "gtex_v8"
              }
            },
            required: ["tissueSiteDetailId"]
          }
        },
        {
          name: "get_clustered_expression",
          description: "Get clustered gene expression data for visualization",
          inputSchema: {
            type: "object",
            properties: {
              gencodeIds: {
                type: "array",
                items: { type: "string" },
                description: "Array of GENCODE gene IDs"
              },
              datasetId: {
                type: "string",
                description: "GTEx dataset ID (default: gtex_v8)",
                default: "gtex_v8"
              }
            },
            required: ["gencodeIds"]
          }
        },
        {
          name: "calculate_expression_correlation",
          description: "Calculate expression correlation between genes across tissues",
          inputSchema: {
            type: "object",
            properties: {
              gencodeIds: {
                type: "array", 
                items: { type: "string" },
                description: "Array of GENCODE gene IDs to compare"
              },
              datasetId: {
                type: "string",
                description: "GTEx dataset ID (default: gtex_v8)",
                default: "gtex_v8"
              }
            },
            required: ["gencodeIds"]
          }
        },
        {
          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"]
          }
        },
    
        // Association Analysis Tools (6 tools)  
        {
          name: "get_eqtl_genes",
          description: "Get genes with eQTL associations for a genomic region",
          inputSchema: {
            type: "object",
            properties: {
              chr: {
                type: "string",
                description: "Chromosome (e.g., chr1, chr2, chrX)"
              },
              start: {
                type: "integer",
                description: "Start position (1-based)"
              },
              end: {
                type: "integer", 
                description: "End position (1-based)"
              },
              tissueSiteDetailId: {
                type: "string",
                description: "Tissue site detail ID (optional, for tissue-specific results)"
              },
              datasetId: {
                type: "string",
                description: "GTEx dataset ID (default: gtex_v8)",
                default: "gtex_v8"
              }
            },
            required: ["chr", "start", "end"]
          }
        },
        {
          name: "get_single_tissue_eqtls", 
          description: "Get single-tissue eQTL results for a gene",
          inputSchema: {
            type: "object",
            properties: {
              gencodeId: {
                type: "string",
                description: "GENCODE gene ID (e.g., ENSG00000223972.5)"
              },
              tissueSiteDetailId: {
                type: "string",
                description: "Tissue site detail ID (e.g., Muscle_Skeletal, Brain_Cortex)"
              },
              datasetId: {
                type: "string",
                description: "GTEx dataset ID (default: gtex_v8)",
                default: "gtex_v8"
              }
            },
            required: ["gencodeId", "tissueSiteDetailId"]
          }
        },
        {
          name: "calculate_dynamic_eqtl",
          description: "Calculate dynamic eQTL effects across tissues",
          inputSchema: {
            type: "object",
            properties: {
              gencodeId: {
                type: "string", 
                description: "GENCODE gene ID (e.g., ENSG00000223972.5)"
              },
              snpId: {
                type: "string",
                description: "SNP ID (rs number or variant ID)"
              },
              tissueSiteDetailIds: {
                type: "array",
                items: { type: "string" },
                description: "Array of tissue site detail IDs to compare"
              },
              datasetId: {
                type: "string",
                description: "GTEx dataset ID (default: gtex_v8)",
                default: "gtex_v8"
              }
            },
            required: ["gencodeId", "snpId", "tissueSiteDetailIds"]
          }
        },
        {
          name: "get_multi_tissue_eqtls",
          description: "Get multi-tissue eQTL meta-analysis results", 
          inputSchema: {
            type: "object",
            properties: {
              gencodeId: {
                type: "string",
                description: "GENCODE gene ID (e.g., ENSG00000223972.5)"
              },
              datasetId: {
                type: "string",
                description: "GTEx dataset ID (default: gtex_v8)",
                default: "gtex_v8"
              }
            },
            required: ["gencodeId"]
          }
        },
        {
          name: "get_sqtl_results",
          description: "Get splicing QTL (sQTL) results for a gene",
          inputSchema: {
            type: "object",
            properties: {
              gencodeId: {
                type: "string",
                description: "GENCODE gene ID (e.g., ENSG00000223972.5)"
              },
              tissueSiteDetailId: {
                type: "string",
                description: "Tissue site detail ID (optional, for tissue-specific results)"
              },
              datasetId: {
                type: "string",
                description: "GTEx dataset ID (default: gtex_v8)",
                default: "gtex_v8"
              }
            },
            required: ["gencodeId"]
          }
        },
        {
          name: "analyze_ld_structure",
          description: "Analyze linkage disequilibrium structure around eQTL variants",
          inputSchema: {
            type: "object",
            properties: {
              chr: {
                type: "string",
                description: "Chromosome (e.g., chr1, chr2, chrX)"
              },
              position: {
                type: "integer",
                description: "Genomic position (1-based)"
              },
              windowSize: {
                type: "integer",
                description: "Window size around position (default: 100000)",
                default: 100000
              },
              population: {
                type: "string",
                description: "Population for LD analysis (default: EUR)", 
                enum: ["EUR", "AFR", "AMR", "EAS", "SAS"],
                default: "EUR"
              }
            },
            required: ["chr", "position"]
          }
        },
    
        // Reference/Dataset Tools (12 tools)
        {
          name: "search_genes",
          description: "Search for genes by symbol, name, or description",
          inputSchema: {
            type: "object",
            properties: {
              query: {
                type: "string",
                description: "Search query (gene symbol, name, or description)"
              },
              species: {
                type: "string", 
                description: "Species (default: human)",
                enum: ["human", "mouse"],
                default: "human"
              },
              page: {
                type: "integer",
                description: "Page number for pagination (default: 0)",
                default: 0
              },
              pageSize: {
                type: "integer",
                description: "Number of results per page (default: 250)",
                default: 250
              }
            },
            required: ["query"]
          }
        },
        {
          name: "get_gene_info",
          description: "Get detailed information about a specific gene",
          inputSchema: {
            type: "object",
            properties: {
              gencodeId: {
                type: "string",
                description: "GENCODE gene ID (e.g., ENSG00000223972.5)"
              },
              geneSymbol: {
                type: "string",
                description: "Gene symbol (alternative to gencodeId)"
              }
            }
          }
        },
        {
          name: "get_variants",
          description: "Get genetic variants in a genomic region",
          inputSchema: {
            type: "object",
            properties: {
              chr: {
                type: "string",
                description: "Chromosome (e.g., chr1, chr2, chrX)"
              },
              start: {
                type: "integer",
                description: "Start position (1-based)"
              },
              end: {
                type: "integer",
                description: "End position (1-based)"
              },
              datasetId: {
                type: "string",
                description: "GTEx dataset ID (default: gtex_v8)",
                default: "gtex_v8"
              }
            },
            required: ["chr", "start", "end"]
          }
        },
        {
          name: "get_tissue_info",
          description: "Get information about GTEx tissues and sample counts",
          inputSchema: {
            type: "object",
            properties: {
              datasetId: {
                type: "string",
                description: "GTEx dataset ID (default: gtex_v8)",
                default: "gtex_v8"
              }
            }
          }
        },
        {
          name: "get_sample_info",
          description: "Get GTEx sample metadata and demographics",
          inputSchema: {
            type: "object",
            properties: {
              tissueSiteDetailId: {
                type: "string",
                description: "Tissue site detail ID (optional, for tissue-specific samples)"
              },
              datasetId: {
                type: "string", 
                description: "GTEx dataset ID (default: gtex_v8)",
                default: "gtex_v8"
              }
            }
          }
        },
        {
          name: "get_subject_phenotypes",
          description: "Get subject phenotype data and demographics",
          inputSchema: {
            type: "object",
            properties: {
              subjectId: {
                type: "string",
                description: "GTEx subject ID (optional, for specific subject)"
              },
              datasetId: {
                type: "string",
                description: "GTEx dataset ID (default: gtex_v8)", 
                default: "gtex_v8"
              }
            }
          }
        },
        {
          name: "validate_gene_id",
          description: "Validate and normalize gene identifiers",
          inputSchema: {
            type: "object",
            properties: {
              geneId: {
                type: "string",
                description: "Gene ID to validate (GENCODE ID or gene symbol)"
              }
            },
            required: ["geneId"]
          }
        },
        {
          name: "validate_variant_id", 
          description: "Validate variant identifiers and genomic coordinates",
          inputSchema: {
            type: "object",
            properties: {
              variantId: {
                type: "string",
                description: "Variant ID to validate (rs number or variant ID)"
              },
              chr: {
                type: "string",
                description: "Chromosome (alternative validation method)"
              },
              position: {
                type: "integer",
                description: "Genomic position (alternative validation method)"
              }
            }
          }
        },
        {
          name: "get_dataset_info",
          description: "Get information about available GTEx datasets",
          inputSchema: {
            type: "object",
            properties: {
              datasetId: {
                type: "string",
                description: "Specific dataset ID (optional, returns all if not provided)"
              }
            }
          }
        },
        {
          name: "search_transcripts",
          description: "Search for gene transcripts and isoforms",
          inputSchema: {
            type: "object",
            properties: {
              gencodeId: {
                type: "string",
                description: "GENCODE gene ID (e.g., ENSG00000223972.5)"
              },
              transcriptType: {
                type: "string",
                description: "Transcript type filter (optional)",
                enum: ["protein_coding", "lncRNA", "pseudogene", "miRNA"]
              }
            },
            required: ["gencodeId"]
          }
        },
        {
          name: "get_gene_ontology",
          description: "Get Gene Ontology annotations for a gene",
          inputSchema: {
            type: "object",
            properties: {
              gencodeId: {
                type: "string",
                description: "GENCODE gene ID (e.g., ENSG00000223972.5)"
              },
              ontologyType: {
                type: "string", 
                description: "GO ontology type (optional)",
                enum: ["biological_process", "cellular_component", "molecular_function"]
              }
            },
            required: ["gencodeId"]
          }
        },
        {
          name: "convert_coordinates",
          description: "Convert between different genomic coordinate systems",
          inputSchema: {
            type: "object",
            properties: {
              chr: {
                type: "string",
                description: "Chromosome (e.g., chr1, chr2, chrX)"
              },
              position: {
                type: "integer",
                description: "Genomic position to convert"
              },
              fromBuild: {
                type: "string",
                description: "Source genome build (default: hg38)",
                enum: ["hg19", "hg38"],
                default: "hg38"
              },
              toBuild: {
                type: "string", 
                description: "Target genome build (default: hg19)",
                enum: ["hg19", "hg38"],
                default: "hg19"
              }
            },
            required: ["chr", "position"]
          }
        }
      ]
    };
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, the description doesn't address important behavioral aspects like rate limits, authentication requirements, data freshness, or what format the clustered data takes (heatmap coordinates, hierarchical clustering results, etc.). The 'for visualization' hint is minimal context.

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 communicates the core purpose without unnecessary words. It's appropriately sized for a tool with two parameters and no complex behavioral requirements, though this conciseness comes at the expense of completeness.

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?

For a tool with no annotations, no output schema, and multiple similar sibling tools, the description is insufficient. It doesn't explain what 'clustered' means operationally, what visualization formats are supported, or how this differs from other expression tools. The agent would struggle to use this tool correctly without additional context.

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 both parameters are documented in the schema. The description adds no additional parameter information beyond what's already in the schema. The baseline score of 3 reflects adequate parameter documentation through the schema alone, with no value added by the description.

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') and resource ('clustered gene expression data'), with the purpose 'for visualization' providing additional context about the output's intended use. However, it doesn't explicitly differentiate this tool from sibling tools like 'get_gene_expression' or 'get_median_gene_expression', which likely provide similar data in different formats.

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 multiple sibling tools related to gene expression (get_gene_expression, get_median_gene_expression, get_differential_expression), there's no indication of when clustered expression data is preferred over other expression data types or what visualization scenarios this tool supports.

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