Swarchal / platetools

An R package for plotting microtitre plates
Other
54 stars 15 forks source link

Change symbol and sizes for 384 and 96-well plates? #31

Open imkidd57 opened 2 years ago

imkidd57 commented 2 years ago

Hi Scott - is there any way to pass parameters to change the size of the squares in 384-well maps, and swap the circles for squares in 96-well maps? Basically I am considering to reduce the whitespace between the squares in raw_map, and change the symbols in z_grid to also be squares.

I'm not new to R but also not at a particularly advanced level. Looking at the source code for plt384 it seems possible, but wondered if there was a simpler way than trying to adapt it.

Kind regards

mike

Swarchal commented 2 years ago

Hi Mike,

It should be possible without making any changes. Any additional arguments you give to the plotting functions are passed to ggplot2's geom_point(), so you can use any valid size and shape values. I also added a little helper so you can use shape="square" or shape="circle" rather than shape=22 or shape=21`.

e.g

library(platetools)

df = data.frame(val = rnorm(96), well = num_to_well(1:96))

raw_map(df$val, df$well, shape = "square", size = 15)

image

imkidd57 commented 2 years ago

Hi Scott

Thanks so much for this advice and helper code. Using this, it works a treat.

Our 384-well plates are convoluted by interwoven four 96-well plate quadrants, and all now break out nicely into images that make viewing easier (Q4 is a blank). The values scale is wrong - should be 12-14 max - but I think I know how to fix that.

Snippet and .png using platetools _zgrid:

z_grid(main_table$n_FAM, main_table$96-coord, shape = "square", size = 14, plate_id = main_table$Quadrant) + scale_fill_gradientn(colours = c("white", "tomato3"))

Thanks again for the quick response!

n_FAM_quad

imkidd57 commented 2 years ago

sorry closed by mistake!

Swarchal commented 2 years ago

Unless I've misunderstood, your values are unexpected because you're using z_grid which returns z-scored values, if you want to see the raw values then raw_grid() is the function you want.

imkidd57 commented 2 years ago

Thanks Scott - I had somehow overlooked raw_grid. Of course it turned out that I did not know a way to fix the previous legend scale, but using raw_grid does return the expected range to it. Much appreciated!