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).
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
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')
Parsing ADAT in R
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')
Last updated
Was this helpful?