jpquast / ggplate

Create Layout Plots of Biological Culture Plates and Microplates
https://jpquast.github.io/ggplate/
Other
90 stars 6 forks source link

Export of plate format #11

Closed UnfuhlberWatcher closed 10 months ago

UnfuhlberWatcher commented 1 year ago

Is it possible to take the plate layout and export in a spreadsheet format?

jpquast commented 11 months ago

Hi @UnfuhlberWatcher, sorry for the late reply! You can just convert the input data yourself to be in a spreadsheet format (see below). Let me know if this is what you meant and if it answers your question!

library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(tidyr)
library(stringr)
library(ggplate)
#> 📊 Welcome to ggplate version 0.0.1! 📈
#>                             
#> 🖍 Have fun plotting your data! 💻

# Load data
data("data_continuous_96")

# Input data format
data_continuous_96
#> # A tibble: 96 × 2
#>    Value well 
#>    <dbl> <chr>
#>  1  1.19 A1   
#>  2  0.88 A2   
#>  3  0.17 A3   
#>  4  0.85 A4   
#>  5  0.78 A5   
#>  6  0.23 A6   
#>  7  1.95 A7   
#>  8  0.4  A8   
#>  9  0.88 A9   
#> 10  0.26 A10  
#> # ℹ 86 more rows

# Output data format
data_continuous_96 %>% 
  mutate(column = str_extract(well, pattern = "[:alpha:]+"),
         row = str_extract(well, pattern = "\\d+")) %>% 
  select(-c(well)) %>% 
  pivot_wider(names_from = column, values_from = Value) %>% 
  select(-c(row))
#> # A tibble: 12 × 8
#>        A     B     C     D     E     F     G     H
#>    <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#>  1  1.19  0.05  0.26  1.71  1     0.5   0.36  1.13
#>  2  0.88  0.97  2.12  0.41  0.47  0.07  0.5   0.83
#>  3  0.17  0.9   0.17  0.35  0.05  0.2   0.65  1.11
#>  4  0.85  0.02  0.83  1.24  0.17  0.67  0.03  0.19
#>  5  0.78  2.06  0.75  1.82  0.08  0.63  1.51  0.64
#>  6  0.23  1.01  0.25  1.17  0.67  1.65  0.37  0.32
#>  7  1.95  0.92  0.62  0.33  1.4   0.64  0.11  0.51
#>  8  0.4   1.66  0.28  0.51  0.35  0.38  0.1   1.64
#>  9  0.88  0.12  1.36  0.23  1.05  0.87  0.39  0.85
#> 10  0.26  0.41  0.18  0.41  0.62  1.68  0.07  0.32
#> 11  1.47  1.7   0.04  0.33  1.82  1.41  0.84  1.12
#> 12  3.04  0.24  0.03  2.73  0.1   0.98  0.41  0.91

Created on 2023-11-09 with reprex v2.0.2