Merge two mass_dataset objects. More information can be found here https://tidymass.github.io/massdataset/articles/process_info.html

merge_mass_dataset(
  x,
  y,
  sample_direction = c("left", "right", "full", "inner"),
  variable_direction = c("left", "right", "full", "inner"),
  sample_by = c("sample_id"),
  variable_by = c("variable_id", "mz", "rt")
)

Arguments

x

(required) A mass_dataset class object.

y

(required) A mass_dataset class object.

sample_direction

How to merge samples, should be left, right, inner or full. See ?left_join

variable_direction

How to merge variables, should be left, right, inner or full.

sample_by

merge samples by what columns from sample_info.

variable_by

merge variables by what columns from variable_info

Value

A merged mass_dataset.

Author

Xiaotao Shen shenxt1990@outlook.com

Examples

data("expression_data")
data("sample_info")
data("variable_info")

object =
  create_mass_dataset(
    expression_data = expression_data,
    sample_info = sample_info,
    variable_info = variable_info,
  )

x = object[1:3, 5:7]
y = object[2:4, 6:8]

####full merge for samples and variables
z1 =
merge_mass_dataset(
  x = x,
  y = y,
  sample_direction = "full",
  variable_direction = "full"
)

####inner merge for samples and full merge for variables
z2 =
  merge_mass_dataset(
    x = x,
    y = y,
    sample_direction = "inner",
    variable_direction = "full"
  )

extract_expression_data(x)
#>                   PS4P1     PS4P2   PS4P3
#> M136T55_2_POS 1494436.1 3496912.1 1959179
#> M79T35_POS    2471336.1 3333582.7 2734244
#> M307T548_POS   288590.2  137297.5      NA
extract_expression_data(y)
#>                  PS4P2   PS4P3     PS4P4
#> M79T35_POS   3333582.7 2734244 3361452.3
#> M307T548_POS  137297.5      NA  271318.3
#> M183T224_POS 5059068.1 5147422        NA
extract_expression_data(z1)
#>                   PS4P1     PS4P2   PS4P3     PS4P4
#> M136T55_2_POS 1494436.1 3496912.1 1959179        NA
#> M79T35_POS    2471336.1 3333582.7 2734244 3361452.3
#> M307T548_POS   288590.2  137297.5      NA  271318.3
#> M183T224_POS         NA 5059068.1 5147422        NA
extract_expression_data(z2)
#>                   PS4P2   PS4P3
#> M136T55_2_POS 3496912.1 1959179
#> M79T35_POS    3333582.7 2734244
#> M307T548_POS   137297.5      NA
#> M183T224_POS  5059068.1 5147422

######combine pos and neg
x = object[1:3, 5:7]
y = object[4:6, 6:8]

z3 =
  merge_mass_dataset(
    x = x,
    y = y,
    sample_direction = "full",
    variable_direction = "full"
  )

extract_expression_data(z3)
#>                   PS4P1     PS4P2   PS4P3   PS4P4
#> M136T55_2_POS 1494436.1 3496912.1 1959179      NA
#> M79T35_POS    2471336.1 3333582.7 2734244      NA
#> M307T548_POS   288590.2  137297.5      NA      NA
#> M183T224_POS         NA 5059068.1 5147422      NA
#> M349T47_POS          NA 8424315.6 7896633 6441449
#> M182T828_POS         NA 4600172.4 5557015 4433034