> For the complete documentation index, see [llms.txt](https://documentation.dnanexus.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.dnanexus.com/developer/walkthroughs/creating-a-mixed-phenotypic-assay-dataset.md). Agents can also search and read this documentation through its [MCP server](https://documentation.dnanexus.com/~gitbook/mcp).

# Creating a Mixed Phenotypic Assay Dataset

Learn to create an Apollo dataset incorporating both phenotypic and assay data.

{% hint style="info" %}
An Apollo license is required to use the apps mentioned in this guide. Org approval may also be required. [Contact DNAnexus Sales](mailto:sales@dnanexus.com) for more information.
{% endhint %}

## Introduction

The following is an example of the process to create a mixed phenotypic and assay Apollo Dataset. You have an existing longitudinal clinical Dataset, "Initial Trial", and recently received three new sets of data from a lab experiment, "Experiment A". The three sets of data are two data files with information from the patient's visit (New data 1) and the visit's lab tests (New data 2). You also have a gene expression matrix for the molecular data (New data 3) which measures mRNA expression levels from isolated tissues corresponding to the visit.

```mermaid
flowchart LR
    subgraph initialTrial["Initial Trial Dataset"]
        patients@{ shape: lin-rect, label: "Patients" }
        baselineTests@{ shape: lin-rect, label: "Baseline Tests" }
        patients --- baselineTests
    end
    newData12@{ shape: st-rect, label: "<b>New Data 1, 2</b><br/>Experiment A visit data<br/>(Visit Info and Lab Measures)" }
    newData3@{ shape: lin-rect, label: "<b>New Data 3</b><br/>Experiment A bulk RNAseq<br/>Gene Expression Matrix" }
    initialTrial ~~~ newData12
    newData12 ~~~ newData3

    %% Styling
    classDef datasetGroup fill:#18ADF1,stroke:#121249,stroke-width:2px,color:#121249
    classDef dataNode fill:#F6F7FA,stroke:#121249,stroke-width:2px,color:#121249

    class initialTrial datasetGroup
    class patients,baselineTests,newData12,newData3 dataNode
```

As the data administrator, you want to add the two new sets of data to the existing Dataset and update your sample cohort, "Demo", to reference the newly expanded Dataset.

## Guide

### Step 1: Ingest the Lab Measurements

Since the new lab measurements are complex and contain information for visits and a series of measurements for each visit, use the [Data Model Loader](https://platform.dnanexus.com/app/data_model_loader_v2) app to [ingest the data](https://documentation.dnanexus.com/developer/walkthroughs/guide-for-ingesting-a-four-table-dataset.md), ensuring that your "Visit" Entity contains a `patient_id`, and create a Dataset named "RNAseq study lab measurements". This Dataset contains two Entities.

```mermaid
flowchart TB
    subgraph studyDataset["RNAseq study lab measurements"]
        subgraph studyEntities["Entities"]
            visits@{ shape: lin-rect, label: "Visits" }
            labs@{ shape: lin-rect, label: "Labs" }
            visits --- labs
        end
    end

    %% Styling
    classDef datasetGroup fill:#18ADF1,stroke:#121249,stroke-width:2px,color:#121249
    classDef entityGroup fill:#F6F7FA,stroke:#121249,stroke-width:2px,color:#121249
    classDef dataNode fill:#F6F7FA,stroke:#121249,stroke-width:2px,color:#121249

    class studyDataset datasetGroup
    class studyEntities entityGroup
    class visits,labs dataNode
```

### Step 2: Ingest the Gene Expression Matrix

Using the [Molecular Expression Assay Loader](https://platform.dnanexus.com/app/molecular-expression-assay-loader) app, ingest the gene expression matrix and create a Dataset named "RNAseq gem". This Dataset contains Molecular Expression assay data, and a single Entity that contains sample ID information.

```mermaid
flowchart LR
    subgraph gemDataset["RNAseq gem"]
        subgraph gemEntities["Entities"]
            sample@{ shape: lin-rect, label: "Sample" }
        end
        molecularAssay["<b>Molecular Expression Assay</b>"]
        sample --- molecularAssay
    end

    %% Styling
    classDef datasetGroup fill:#18ADF1,stroke:#121249,stroke-width:2px,color:#121249
    classDef entityGroup fill:#F6F7FA,stroke:#121249,stroke-width:2px,color:#121249
    classDef dataNode fill:#F6F7FA,stroke:#121249,stroke-width:2px,color:#121249

    class gemDataset datasetGroup
    class gemEntities entityGroup
    class sample,molecularAssay dataNode
```

### Step 3: Add the Lab Measurements to the Initial Dataset

Using the [Clinical Dataset Merger](https://platform.dnanexus.com/app/clinical_dataset_merger) app, link the "RNAseq study lab measurements" Dataset to the target "Initial Trial" Dataset to create an output Dataset named "Initial trial with RNAseq (pheno only)". Do this by adding the "RNAseq study lab measurements" Dataset as the **Source Dataset** input parameter and the "Initial Trial" Dataset as the **Target Dataset** input parameter.

This new Dataset has the original two Entities and the two additional Entities merged in.

### Step 4: Add the Gene Expression Matrix to the Expanded Dataset

Using the [Assay Dataset Merger](https://platform.dnanexus.com/app/assay_dataset_merger) app, use the "RNAseq gem" Dataset as the **Source Dataset** input parameter and the "Initial trial with RNAseq (pheno only)" Dataset as the **Target Dataset** input parameter to create an output Dataset named "Initial trial with RNAseq". This new Dataset has the new measurements as Entities and the gene expression matrix linked as an assay.

```mermaid
flowchart TB
    subgraph expandedDataset["Initial trial with RNAseq"]
        subgraph expandedEntities["Entities"]
            patient@{ shape: lin-rect, label: "Patient" }
            baselineTests@{ shape: lin-rect, label: "Baseline Tests" }
            visits@{ shape: lin-rect, label: "Visits" }
            labs@{ shape: lin-rect, label: "Labs" }
            patient --- baselineTests
            patient --- visits
            visits --- labs
        end
        assay["<b>Molecular Expression Assay</b>"]
        visits --- assay
    end

    %% Styling
    classDef datasetGroup fill:#18ADF1,stroke:#121249,stroke-width:2px,color:#121249
    classDef entityGroup fill:#F6F7FA,stroke:#121249,stroke-width:2px,color:#121249
    classDef dataNode fill:#F6F7FA,stroke:#121249,stroke-width:2px,color:#121249

    class expandedDataset datasetGroup
    class expandedEntities entityGroup
    class patient,baselineTests,visits,labs,assay dataNode
```

### Step 5: Rebase the Cohort on the New Dataset

Before sharing the Dataset you still need to update the "Demo" cohort so that it opens with the new Dataset. Using the [Rebase Cohorts And Dashboards](https://platform.dnanexus.com/app/rebase_cohorts_and_dashboards) app, rebase the "Demo" cohort onto the "Initial trial with RNAseq" Dataset using the **Cohorts** input parameter and generate a "Demo RNAseq" cohort with the suffix "RNAseq". The new Dataset, ingested databases, and cohort are ready to be shared and used for analysis.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://documentation.dnanexus.com/developer/walkthroughs/creating-a-mixed-phenotypic-assay-dataset.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
