Skip to contents

Checks for columns which are uniquely identified by a group of identifiers. This should be used to help identify the columns required to uniquely identify the rows, columns, assays and metadata of a DataMapper class object.

Usage

# S4 method for LongTableDataMapper
guessMapping(object, groups, subset, data = FALSE)

Arguments

object

A LongTableDataMapper object.

groups

A list containing one or more vector of column names to group-by. The function uses these to determine 1:1 mappings between the combination of columns in each vector and unique values in the raw data columns.

subset

A logical vector indicating whether to to subset out mapped columns after each grouping. Must be a single TRUE or FALSE or have the same length as groups, indicating whether to subset out mapped columns after each grouping. This will prevent mapping a column to two different groups.

data

A logical vector indicating whether you would like the data for mapped columns to be returned instead of their column names. Defaults to FALSE for easy use assigning mapped columns to a DataMapper object.

Value

A list, where each item is named for the associated groups item the guess is for. The character vector in each item are columns which are uniquely identified by the identifiers from that group.

Details

Any unmapped columns will be added to the end of the returned list in an item called unmapped.

The function automatically guesses metadata by checking if any columns have only a single value. This is returned as an additional item in the list.

Examples

guessMapping(exampleDataMapper, groups=list(rows='treatmentid', cols='sampleid'),
subset=FALSE)
#> [CoreGx::guessMapping,LongTableDataMapper-method]
#> 	Mapping for group rows: treatmentid
#> [CoreGx::guessMapping,LongTableDataMapper-method]
#> 	Mapping for group cols: sampleid
#> $metadata
#> $metadata$id_columns
#> [1] NA
#> 
#> $metadata$mapped_columns
#> [1] "metadata"
#> 
#> 
#> $rows
#> $rows$id_columns
#> [1] "treatmentid"
#> 
#> $rows$mapped_columns
#> character(0)
#> 
#> 
#> $cols
#> $cols$id_columns
#> [1] "sampleid"
#> 
#> $cols$mapped_columns
#> character(0)
#> 
#> 
#> $unmapped
#> [1] "viability"
#>