name: Thematic analysis
version: 0.1.0
description: A qualitative thematic analysis of transcript data, based on reflexive thematic analysis. Codes are generated independently for each document, and then clustered and combined before being used to generate themes.
default_context:
  persona:
    default: Experienced qualitative researcher
    description: Analyst persona
    help_text: The perspective and expertise from which the analysis is conducted.
  research_question:
    default: To understand the experience of participants
    description: Research question
    help_text: The main question guiding the thematic analysis
  theme_size_guidance:
    default: "Produce 7-10 themes. Strongly prefer fewer/larger themes with greater explanatory depth and power. Combine overlapping themes, creating a richer, more nuanced analysis."
    description: Guidance on the number of themes to produce.
    help_text: ""
    input_type: textarea
  max_themes:
    default: 12
    description: Maximum number of themes to generate
    help_text: Maximum number of themes to generate (hard cap)
  min_themes:
    default: 3
    description: Minimum number of themes to generate
    help_text: Minimum number of themes to generate (hard cap)
  specific_research_question:
    default: ""
    description: Specific research focus
    help_text: (Optional) specific aspect or sub-question to focus on. This text can direct code and theme-formation.
    input_type: textarea
  
scrub: false
randomise_document_order: true
config:
    report_texts: 
      narrative.meta_narrative:
        label: Summary
        description: Overarching narrative account of the analysis.
      narrative.narrative:
        label: Thematic Narrative
        description: Narrative report

default_config:
  models:
    default: gpt-4.1-mini
    best: gpt-4.1-mini
    cheap: gpt-4.1-mini
  embeddings: text-embedding-3-large
  seed: 1

methodology_templates:
  overview: |
      

nodes:
  - name: chunks
    type: Split
    split_unit: words
    chunk_size: 15000
    min_split: 500
    overlap: 200
    inputs:
      - documents
      
  - name: codes_from_chunks
    type: Map
    template: initial_codes.sd
    model: default
    inputs:
      - chunks

  - name: groupedcodes
    type: Cluster
    inputs: [codes_from_chunks]
    items_field: codes      # extract Code objects from CodeList.codes
    method:
      name: hdbscan
      min_cluster_size: 2
      max_cluster_size: 50
      
  - name: consolidated_codes
    type: Map
    inputs: [groupedcodes]
    model: default
    template: consolidate_codes.sd

  - name: codes
    type: Reduce
    items_field: codes
    inputs: [consolidated_codes]
  
  - name: checkquotes
    type: VerifyQuotes
    model: cheap
    inputs: [codes]
    check_fairness: false
    
  - name: big_code_groups
    type: Cluster
    inputs: [codes]
    items_field: codes
    method:
      name: hdbscan
      min_cluster_size: 50
      
  - name: theme_groups
    type: Map
    template: make_theme_group.sd
    model: best
    inputs:
      - big_code_groups

  - name: flat_themes
    type: Reduce
    items_field: themes
    inputs:
      - theme_groups
    
  - name: themes
    type: Transform
    template: final_themes.sd
    model: best
    inputs:
      - theme_groups

  - name: narrative
    type: Transform
    template: narrative_report.sd
    temperature: 1.0
    model: best
    inputs:
      - themes
