All pages
Powered by GitBook
1 of 2

Loading...

Loading...

Using the ADAT

ADATs can be analyzed in R or Python using parsers created by Somalogic.

DRAGEN Protein Quantification v2.0.0 is compatible with SomaData v1.0.0 (Python - formerly called Canopy) and SomaDataIO v6.1.0 (R).

  • Python: https://github.com/SomaLogic/Canopy

  • R: https://github.com/SomaLogic/SomaDataIO

Somadata creates an ADAT object, which is an extension of a Pandas DataFrame.

  • rows correspond to samples

  • columns correspond to SOMAmers

  • values are normalized counts

Below are examples on parsing an ADAT in Python and R.

Parsing ADAT in Python

Parsing ADAT in R

import somadata

# read the adat
my_adat = somadata.read_adat('/path/to/my/file1.adat')

# retrieve sample metadata
sample_meta = my_adat.index.to_frame(index=False)

# retrieve SOMAmer metadata
soma_meta = my_adat.columns.to_frame(index=False)

# retrieve the scale factors for all plates
plate_scale_factors_dict = my_adat.header_metadata['PlatformSpecificPlateScale_ScaleFactor']

### additional optional manipulation 

# concatenate multiple adats into a single adat
my_adat2 = somadata.read_adat('/path/to/my/file2.adat')
my_merged_adat = soma.smart_adat_concatenation([my_adat, my_adat2])

# write it to a file 
my_merged_adat = my_merged_adat.to_adat('/path/to/merged/adat')
library(SomaDataIO)

# check all package functions
ls("package:SomaDataIO")

#read the adat
my_adat <- read_adat('/path/to/my/file1.adat')

# retrieve sample metadata
sample_meta <- my_adat[getMeta(my_adat)]

# retrieve SOMAmer metadata
soma_meta <- my_adat[getAnalytes(my_adat)]

# create a function that parses the header
parse_adat_header <- function(adat_file, max_lines = 500) {
  header_lines <- readLines(adat_file, n = max_lines)
  table_row <- grep("TABLE_BEGIN", header_lines)
  header_lines[1:(table_row-1)] %>% 
    strsplit("\t") %>% 
    {
      values <- map(., 2) # Get values from key value pairs
      keys <- map_chr(., 1) # Get keys...
      setNames(values, keys)
    }
}

my_adat_header <- parse_adat_header('/path/to/my/file1.adat')

# retrieve the scale factors for all plates
plate_scale_factors_dict = my_adat_header$PlatformSpecificPlateScale_ScaleFactor

### additional optional manipulation 
my_adat2 = read_adat('/path/to/my/file2.adat')
my_merged_adat = rbind(my_adat, my_adat2)

# write it to a file 
my_merged_adat = write_adat(my_merged_adat, '/path/to/merged/adat')

Compatibility with Excel

While using the R and Python parsers is the recommended way to manipulate ADAT files, it's also possible to open and view them in Excel.

Opening an ADAT in Excel (Windows)

  1. Open a blank excel workbook and browse for a file.

  2. Confirm that "All Files (*.*)" are searchable.

  1. Accept default parameters from Excel.

  1. View ADAT in Excel!

Opening an ADAT in Excel (Mac)

  1. Open a blank excel workbook and select File --> Import.

  1. Select the previously downloaded .adat file.

  1. After Click on "Get Data", select "Text file" and click on "Import".

  1. Select Delimited (default) and click on "Next >".

  1. Select "Tab" (default) and click on "Next >".

  1. Select "General" (default) and click on "Next >".

  1. Select the sheet and click on "Import".

  1. View the ADAT in Excel!