This is an example of how to run MACSQuantifyR with combination drug analysis. To know more about the package, have a look at the introduction vignette

In this vignette we will run the MACSQuantifyR package on the example given in the introduction of the previous vignette. More precisely, this experiment corresponds to the screening of the combination effects of two drugs on human cells.

Here is the plate template chosen by the user that represents drugs alone (up part of the well plate) and combinations (low part of the well plate).


Load the packages

## Attaching package: 'latticeExtra'
## The following object is masked from 'package:ggplot2':
##     layer

Create a new object MACSQuant: new_class_MQ()

This function allows the user to create a new object of class MACSQuant.

This will allow the user to set specific options regarding the experiment and the output of some functions before running other functions.

  • Create the MACSQuant object:
MACSQuant <- new_class_MQ(path = "output_path")
  • Define experiment name:
slot(MACSQuant, "experiment_name") <- "Combo drug1-drug2 HC line 101"
  • Define output path:


Import your data: load_MACSQuant()

Once the excel file has been generated by miltenyi MACSQuantify software. The user can load the data with the following function.

It will generate a variable called my_data, necessary for the next steps of the analysis.

Load the data:

filepath <- system.file("extdata", "drugs.xlsx",
    package = "MACSQuantifyR")
MACSQuant <- load_MACSQuant(filepath,
    sheet_name = "combo_drugs",
    MACSQuant.obj = MACSQuant)
## ok
## --> Done: data loaded
## --> Done: data stored in variable MACSQuant@my_data
## ...You can now run on_plate_selection(MACSQuant,num_replicates,number_of_conditions) with your replicates and conditions numbers...

Sort your replicates: on_plate_selection()

By calling the function on_plate_selection() with the number of conditions in the experiment and the number of replicates by conditions, the user will be asked to select sequentially the replicates for each conditions.

Before running the function, the user can define one of the experiment parameters called c_names in which condition names are stored.

Experiment parameters are:

  • c_names: condition names to plot


  • doses: colors for the barplots


# this line is used to created c_names variable
# for this experiment according to selection
slot(MACSQuant, "param.experiment")$c_names <-
    c(sprintf("Drug1_c%d", 1:4), # DRUG1 ALONE
        sprintf("Drug2_c%d", 1:3), # DRUG2 ALONE
        sprintf("D2[1]_D1[%d]", 1:4), # DRUG2_C1 + DRUG1_Cs
        sprintf("D2[2]_D1[%d]", 1:4), # DRUG2_C2 + DRUG1_Cs
        sprintf("D2[3]_D1[%d]", 1:4)) # DRUG2_C3 + DRUG1_Cs

# custom colors can be defined (with control if selected)
plt.col <- c(heat.colors(length(slot(MACSQuant, "param.experiment")$c_names)),

# dose vector of concentration each condition
slot(MACSQuant, "param.experiment")$doses <-
    c(1, 3, 5, 10, # DRUG1 ALONE
        0, 0, 0,                  # DRUG2 ALONE
        1, 3, 5, 10, # DRUG2_C1 ++ DRUG1_Cs
        1, 3, 5, 10, # DRUG2_C2 + DRUG1_Cs
        1, 3, 5, 10  # DRUG2_C3 + DRUG1_Cs
slot(MACSQuant, "param.experiment")$doses.alt <-
    c(0, 0, 0, 0,                # DRUG1 ALONE
        10, 50, 100,              # DRUG2 ALONE
        10, 10, 10, 10,            # DRUG2_C1 + DRUG1_Cs
        50, 50, 50, 50,            # DRUG2_C2 ++ DRUG1_Cs
        100, 100, 100, 100          # DRUG2_C3 ++ DRUG1_Cs

The function is ready to run:

MACSQuant <- on_plate_selection(MACSQuant,
    number_of_replicates = 3,
    number_of_conditions = 19,
    control = TRUE,
    save.files = TRUE)

Once the replicates of all conditions have been identified by the user, the on_plate_selection function will automatically reorder the data stored in the variable my_data into a new variable called my_data_sorted.

During the process of sorting replicates basic statistical analysis for each condition is done (mean and standard deviation of replicates).

This will generate a new variable called statistics necessary for the next part of the pipeline.

2D/3D data representation: barplot_data()

This function allows the user to generate 2D and 3D plots corresponding to two flavours (cell counts, percentages).

Before running the function, the user can define one of the experiment parameters

flavours are:

  • counts: cell count

  • percent: fluorochrome positive cell percentage

Output.parameters are:


  • plt.title: Barplot title

slot(MACSQuant,"param.output")$plt.title this will be used as subtitle for the Word document.

  • plt.labels: Barplot labels


  • the user can also load specific colors:
plt.col <-
        heat.colors(length(slot(MACSQuant, "param.experiment")$c_names)), 1)

plt.labels <- c(slot(MACSQuant, "param.experiment")$c_names, "Control")

slot(MACSQuant, "param.output")$plt.title <- "Custom title example"

The barplot_data() function is ready to run

flav <- "counts"
p_counts <- barplot_data(MACSQuant,
    plt.col = plt.col,
    plt.flavour = flav,
    plt.labels = plt.labels,
    plt.combo = TRUE,
    xlab = "Drug1",
    ylab = "Drug2")