DNAnexus Documentation
APIDownloadsIndex of dx CommandsLegal
  • Overview
  • Getting Started
    • DNAnexus Essentials
    • Key Concepts
      • Projects
      • Organizations
      • Apps and Workflows
    • User Interface Quickstart
    • Command Line Quickstart
    • Developer Quickstart
    • Developer Tutorials
      • Bash
        • Bash Helpers
        • Distributed by Chr (sh)
        • Distributed by Region (sh)
        • SAMtools count
        • TensorBoard Example Web App
        • Git Dependency
        • Mkfifo and dx cat
        • Parallel by Region (sh)
        • Parallel xargs by Chr
        • Precompiled Binary
        • R Shiny Example Web App
      • Python
        • Dash Example Web App
        • Distributed by Region (py)
        • Parallel by Chr (py)
        • Parallel by Region (py)
        • Pysam
      • Web App(let) Tutorials
        • Dash Example Web App
        • TensorBoard Example Web App
      • Concurrent Computing Tutorials
        • Distributed
          • Distributed by Region (sh)
          • Distributed by Chr (sh)
          • Distributed by Region (py)
        • Parallel
          • Parallel by Chr (py)
          • Parallel by Region (py)
          • Parallel by Region (sh)
          • Parallel xargs by Chr
  • User
    • Login and Logout
    • Projects
      • Project Navigation
      • Path Resolution
    • Running Apps and Workflows
      • Running Apps and Applets
      • Running Workflows
      • Running Nextflow Pipelines
      • Running Batch Jobs
      • Monitoring Executions
      • Job Notifications
      • Job Lifecycle
      • Executions and Time Limits
      • Executions and Cost and Spending Limits
      • Smart Reuse (Job Reuse)
      • Apps and Workflows Glossary
      • Tools List
    • Cohort Browser
      • Chart Types
        • Row Chart
        • Histogram
        • Box Plot
        • List View
        • Grouped Box Plot
        • Stacked Row Chart
        • Scatter Plot
        • Kaplan-Meier Survival Curve
      • Locus Details Page
    • Using DXJupyterLab
      • DXJupyterLab Quickstart
      • Running DXJupyterLab
        • FreeSurfer in DXJupyterLab
      • Spark Cluster-Enabled DXJupyterLab
        • Exploring and Querying Datasets
      • Stata in DXJupyterLab
      • Running Older Versions of DXJupyterLab
      • DXJupyterLab Reference
    • Using Spark
      • Apollo Apps
      • Connect to Thrift
      • Example Applications
        • CSV Loader
        • SQL Runner
        • VCF Loader
      • VCF Preprocessing
    • Environment Variables
    • Objects
      • Describing Data Objects
      • Searching Data Objects
      • Visualizing Data
      • Filtering Objects and Jobs
      • Archiving Files
      • Relational Database Clusters
      • Symlinks
      • Uploading and Downloading Files
        • Small File Sets
          • dx upload
          • dx download
        • Batch
          • Upload Agent
          • Download Agent
    • Platform IDs
    • Organization Member Guide
    • Index of dx commands
  • Developer
    • Developing Portable Pipelines
      • dxCompiler
    • Cloud Workstation
    • Apps
      • Introduction to Building Apps
      • App Build Process
      • Advanced Applet Tutorial
      • Bash Apps
      • Python Apps
      • Spark Apps
        • Table Exporter
        • DX Spark Submit Utility
      • HTTPS Apps
        • Isolated Browsing for HTTPS Apps
      • Transitioning from Applets to Apps
      • Third Party and Community Apps
        • Community App Guidelines
        • Third Party App Style Guide
        • Third Party App Publishing Checklist
      • App Metadata
      • App Permissions
      • App Execution Environment
        • Connecting to Jobs
      • Dependency Management
        • Asset Build Process
        • Docker Images
        • Python package installation in Ubuntu 24.04 AEE
      • Job Identity Tokens for Access to Clouds and Third-Party Services
      • Enabling Web Application Users to Log In with DNAnexus Credentials
      • Types of Errors
    • Workflows
      • Importing Workflows
      • Introduction to Building Workflows
      • Building and Running Workflows
      • Workflow Build Process
      • Versioning and Publishing Global Workflows
      • Workflow Metadata
    • Ingesting Data
      • Molecular Expression Assay Loader
        • Common Errors
        • Example Usage
        • Example Input
      • Data Model Loader
        • Data Ingestion Key Steps
        • Ingestion Data Types
        • Data Files Used by the Data Model Loader
        • Troubleshooting
      • Dataset Extender
        • Using Dataset Extender
    • Dataset Management
      • Rebase Cohorts and Dashboards
      • Assay Dataset Merger
      • Clinical Dataset Merger
    • Apollo Datasets
      • Dataset Versions
      • Cohorts
    • Creating Custom Viewers
    • Client Libraries
      • Support for Python 3
    • Walkthroughs
      • Creating a Mixed Phenotypic Assay Dataset
      • Guide for Ingesting a Simple Four Table Dataset
    • DNAnexus API
      • Entity IDs
      • Protocols
      • Authentication
      • Regions
      • Nonces
      • Users
      • Organizations
      • OIDC Clients
      • Data Containers
        • Folders and Deletion
        • Cloning
        • Project API Methods
        • Project Permissions and Sharing
      • Data Object Lifecycle
        • Types
        • Object Details
        • Visibility
      • Data Object Metadata
        • Name
        • Properties
        • Tags
      • Data Object Classes
        • Records
        • Files
        • Databases
        • Drives
        • DBClusters
      • Running Analyses
        • I/O and Run Specifications
        • Instance Types
        • Job Input and Output
        • Applets and Entry Points
        • Apps
        • Workflows and Analyses
        • Global Workflows
        • Containers for Execution
      • Search
      • System Methods
      • Directory of API Methods
      • DNAnexus Service Limits
  • Administrator
    • Billing
    • Org Management
    • Single Sign-On
    • Audit Trail
    • Integrating with External Services
    • Portal Setup
    • GxP
      • Controlled Tool Access (allowed executables)
  • Science Corner
    • Scientific Guides
      • Somatic Small Variant and CNV Discovery Workflow Walkthrough
      • SAIGE GWAS Walkthrough
      • LocusZoom DNAnexus App
      • Human Reference Genomes
    • Using Hail to Analyze Genomic Data
    • Open-Source Tools by DNAnexus Scientists
    • Using IGV Locally with DNAnexus
  • Downloads
  • FAQs
    • EOL Documentation
      • Python 3 Support and Python 2 End of Life (EOL)
    • Automating Analysis Workflow
    • Backups of Customer Data
    • Developing Apps and Applets
    • Importing Data
    • Platform Uptime
    • Legal and Compliance
    • Sharing and Collaboration
    • Product Version Numbering
  • Release Notes
  • Technical Support
  • Legal
Powered by GitBook

Copyright 2025 DNAnexus

On this page
  • Before You Begin
  • Project License Requirement
  • Stata License Requirement
  • Launching DXJupyterLab
  • Opening JupyterLab
  • Using Stata Within JupyterLab
  • Working with Project Files
  • Creating a Stata Dataset with Spark

Was this helpful?

Export as PDF
  1. User
  2. Using DXJupyterLab

Stata in DXJupyterLab

Using Stata via DXJupyterlab, working with project files, and creating datasets with Spark.

Last updated 3 days ago

Was this helpful?

is a powerful statistics package for data science. Stata commands and functionality can be accessed on the DNAnexus Platform via , in Jupyter notebooks.

Before You Begin

Project License Requirement

On the DNAnexus Platform, use the to create and edit Jupyter notebooks.

Note that you can only run this app within a project that’s billed to an account with a license that allows the use of both and . if you need to upgrade your license.

Note also that DXJupyterLab is accessible to all users of the UK Biobank Research Analysis Platform and the Our Future Health Trusted Research Environment. A license is required to access DXJupyterLab on the DNAnexus Platform. for more information.

Stata License Requirement

To use Stata on the DNAnexus Platform, you need a valid Stata license. Before launching Stata in a project, you must save your license details according to the instructions below in a plain text file with the extension .json, then upload this file to the project’s root directory. You only need to do this once per project.

Creating a Stata License Details File

Start by creating the file in a text editor, including all the fields shown here, where <user> is your DNAnexus username, and<organization>is the org of which you're a member:

{
  "license": {
    "serialNumber": "<Serial number from Stata>",
    "code": "<Code from Stata>",
    "authorization": "<Authorization from Stata>",
    "user": "<Registered user line 1>",
    "organization": "<Registered user line 2>"
  }
}

Save the file according to the following format, where <username> is your DNAnexus username: .stataSettings.user-<username>.json

Some operating systems may not support the naming of files with a "." as the first character. If this is the case, you can rename the .json file after uploading it to your project by hovering over the name of your file and clicking the pencil icon that appears.

Uploading the Stata License Details File

Open the project in which you want to use Stata. Upload the Stata license details file to the project’s root directory by going to your project's Manage tab, clicking on the Add button on the upper right, and then selecting the Upload data option.

Secure Indirect Format Option for Shared Projects

When working in a shared project, you can take an additional step to avoid exposing your Stata license details to project collaborators.

Create a private project. Then create and save a Stata license details file in that project’s root directory, as per the instructions above.

Within the shared project, create and save a Stata license details file in this format, where project-yyyy is the name of the private project, and file-xxxx is the license details file ID, in that private project:

{
  "licenseFile": {
    "$dnanexus_link": {
      "id": "file-xxxx",
      "project": "project-yyyy"
    }
  }
}

Launching DXJupyterLab

  1. Open the project in which you want to use Stata. From within the project's Manage tab, click the Start Analysis button.

  2. Select the app DXJupyterLab with Python, R, Stata, ML.

  3. Click the Run Selected button. Note that if you haven't run this app before, you'll be prompted to install it. Next, you’ll be taken to the Run Analysis screen.

  4. On the Run Analysis screen, open the Analysis Inputs tab and click the Stata settings file button.

  5. Add your Stata settings file as an input. This is the .json file you created, containing your Stata license details.

  6. In the Common section at the bottom of the Analysis Inputs pane, open the Feature dropdown menu and select Stata.

  7. Click the Start Analysis button at the top right corner of the screen. This will launch the DXJupyterLab app, and take you to the project's Monitor tab, where you can monitor the app's status as it loads.

Note: The app can take some time to load and start running.

Once the analysis starts, you’ll see the notification "Running" appear under the name of the app.

Opening JupyterLab

Click the Monitor tab heading. This will open a list of running and past jobs. Jobs are shown in reverse chronological order, with the most recently launched at the top. The topmost row should show the job you’ve just launched. To open the job and enter the JupyterLab interface, click on the URL shown under Worker URL.

If you do not see the worker URL, click on the name of the job in the Monitor page.

Using Stata Within JupyterLab

Within the JupyterLab interface, open the DNAnexus tab shown at the left edge of the screen.

Open a new Stata notebook by clicking the Stata tile in the Notebooks section.

Working with Project Files

You can download DNAnexus data files to DXJupyterLab container from Stata notebook with:

!dx download project-xxxx:file-yyy

Data files in the current project can also be accessed using a /mnt/project folder from a Stata notebook as follows: To load a DTA file:

use /mnt/project/<path>/data_in.dta

To load a CSV file:

import delimited /mnt/project/<path>/data_in.csv

To write a DTA file to the DXJupyterLab container:

save data_out

To write a CSV file to the DXJupyterLab container:

export delimited data_out.csv

To upload a data file from the DXJupyterLab container to the project, use the following command in a Stata notebook:

!dx upload <file> --destination=<destination>

Alternatively, open a new Launcher tab, open Terminal, and run:

dx upload <file> --destination=<destination>

Note that /mnt/project directory is read-only, so trying to write to it results in an error.

Creating a Stata Dataset with Spark

pandas_df = spark_df.toPandas()

Pandas dataframe can be exported to CSV or Stata DTA files in the JupyterLab container with:

pandas_df.to_stata("data_out.dta")
pandas_df.to_csv("data_out.csv")

To upload a data file from the JupyterLab container to the DNAnexus project in the DXJupyterLab spark cluster app, use

%%bash
dx upload <file>

Once saved to the project, data files can be used in a DXJupyterLab Stata session using the instructions above.

Note that when working on the Research Analysis Platform, you can only create a private credentials project from the .

can be used to query and filter DNAnexus returning a PySpark DataFrame. PySpark Dataframe can be converted to a pandas DataFrame with:

Stata
stata_kernel
DXJupyterLab app
DXJupyterLab
HTTPS apps
Contact DNAnexus Sales
Contact DNAnexus Sales
Research Analysis Platform Projects page
DXJupyterLab spark cluster app
datasets
The location of the DNAnexus tab within the JupyterLab interface.