Prerequisites

Make sure to be familiar with the following tutorials before proceeding:

1. Adding grouping variables

Using the functions introduced in the tutorial on how to extract data you can use cypro extern pipelines to continue your analyis. This might result in new grouping variables that you would like to add to the original cypro object and to integrate in the cypro workflow. You can use the function addClusterVariables() or addMetaVariables() for that matter. They join the data variables in accordance to the joining family of funcions of the dplyr-package.

# your individual analysis resulted in a data.frame containing a new cluster variable
head(example_df)
## # A tibble: 6 x 2
##   cell_id              example_cluster_variable
##   <chr>                <fct>                   
## 1 CID_51_WI_B2_1_WP_1  Cluster_1               
## 2 CID_58_WI_B2_2_WP_1  Cluster_2               
## 3 CID_79_WI_B2_2_WP_1  Cluster_2               
## 4 CID_178_WI_B2_2_WP_1 Cluster_2               
## 5 CID_253_WI_B2_2_WP_1 Cluster_2               
## 6 CID_43_WI_B2_3_WP_1  Cluster_1
# current cluster variables in the cypro object
getClusterVariableNames(object)
## [1] "hcl_euclidean_ward.D_k_4_(voi)" "pam_euclidean_k_4_(voi)"
# add new variables 
object <- 
    addClusterVariables(
        object = object,
        input_df = example_df,
        variable_names = "example_cluster_variable",
        by = "cell_id"
        )

# new cluster variables 
getClusterVariableNames(object)
## [1] "hcl_euclidean_ward.D_k_4_(voi)" "pam_euclidean_k_4_(voi)"       
## [3] "example_cluster_variable"

The same works for variables that are not actual clustering results but are still grouping variables. These are stored in the meta data slot. An example data.frame whose content you might want to integrate in your cypro workflow might look like this.

# data.frame that groups conditions into mechanism of action 
moa_df
## # A tibble: 39 x 2
##    condition      moa                     
##    <chr>          <fct>                   
##  1 PP-2           Epithelial              
##  2 emetine        Protein synthesis       
##  3 AZ258          Aurora kinase inhibitors
##  4 cytochalasin B Actin disruptors        
##  5 ALLN           Protein degradation     
##  6 mitoxantrone   DNA replication         
##  7 AZ-C           Eg5 inhibitors          
##  8 MG-132         Protein degradation     
##  9 AZ841          Aurora kinase inhibitors
## 10 docetaxel      Microtubule stabilizers 
## # ... with 29 more rows

This data.frame needs the variable condition as key which is why we have to add them to the meta data of the cypro-object.

getMetaDf(object)
## # A tibble: 1,250 x 3
##    cell_id              cell_line condition
##    <chr>                <fct>     <fct>    
##  1 CID_51_WI_B2_1_WP_1  MCF7      DMSO     
##  2 CID_58_WI_B2_2_WP_1  MCF7      DMSO     
##  3 CID_79_WI_B2_2_WP_1  MCF7      DMSO     
##  4 CID_178_WI_B2_2_WP_1 MCF7      DMSO     
##  5 CID_253_WI_B2_2_WP_1 MCF7      DMSO     
##  6 CID_43_WI_B2_3_WP_1  MCF7      DMSO     
##  7 CID_108_WI_B2_3_WP_1 MCF7      DMSO     
##  8 CID_228_WI_B2_3_WP_1 MCF7      DMSO     
##  9 CID_194_WI_B2_4_WP_1 MCF7      DMSO     
## 10 CID_207_WI_B2_4_WP_1 MCF7      DMSO     
## # ... with 1,240 more rows
object <- 
    addMetaVariables(
        object = object,
        input_df = moa_df,
        variable_names = "moa",
        by = "condition"
        )

getMetaVariableNames(object)
## [1] "cell_line" "condition" "moa"
getMetaDf(object) %>% 
    group_by(moa, condition) %>%
    slice_sample(n = 1)
## # A tibble: 5 x 4
## # Groups:   moa, condition [5]
##   cell_id             cell_line condition     moa                    
##   <chr>               <fct>     <fct>         <fct>                  
## 1 CID_79_WI_B3_4_WP_3 MCF7      latrunculin B Actin disruptors       
## 2 CID_35_WI_C2_2_WP_3 MCF7      DMSO          DMSO                   
## 3 CID_68_WI_F3_3_WP_6 MCF7      chlorambucil  DNA damage             
## 4 CID_82_WI_F3_4_WP_7 MCF7      etoposide     DNA damage             
## 5 CID_19_WI_E2_4_WP_2 MCF7      taxol         Microtubule stabilizers

All variables added this way are accessible from all cypro functions.

##  [1] "cell_line"                      "condition"                     
##  [3] "moa"                            "hcl_euclidean_ward.D_k_4_(voi)"
##  [5] "pam_euclidean_k_4_(voi)"        "example_cluster_variable"      
##  [7] "well_plate_name"                "well_plate_index"              
##  [9] "well"                           "well_roi"
plotBoxplot(object, variables = "AreaShape_Area", across = "moa")
Figure 1 Variable 'moa' (mechanism of action) is now accessible from all cypro functions.

Figure 1 Variable ‘moa’ (mechanism of action) is now accessible from all cypro functions.