Report n1 and n2 on Baseline

Author

David Colameo

Combined Baseline Liquid Periods

library(ephacRTools)
library(ggplot2)
library(dplyr)
library(SingleCellExperiment)
library(DT)


se.n1 <- readRDS("~/dev/r-projects/general/KCNQ2_SMarashili/passedQC_LType.rds")
se.n2 <- readRDS("~/dev/r-projects/general/KCNQ2_SMarashili/n2_pharmacology/passedQC_n2.rds")


assays(se.n1)$CD.peak <- assays(se.n1)$Peak / assays(se.n1)$Capacitance
assays(se.n1)$CD.iss <- assays(se.n1)$ISS / assays(se.n1)$Capacitance
se.n1$Peakat0 <- as.vector(t(assays(se.n1[rowData(se.n1)$V_Clamp == 0,])$Peak))
assays(se.n1)$NormTail <- t(t(assays(se.n1)$Tail) / se.n1$Peakat0)
assays(se.n1)$Decay <- assays(se.n1)$Peak - assays(se.n1)$ISS
assays(se.n1)$CD.decay <- assays(se.n1)$Decay / assays(se.n1)$Capacitance
assays(se.n1)$CD.tail <- assays(se.n1)$Tail / assays(se.n1)$Capacitance
assays(se.n2)$CD.decay <- assays(se.n2)$Decay / assays(se.n2)$Capacitance

assays(se.n2)$CD.tail <- assays(se.n2)$Tail / assays(se.n2)$Capacitance
se.n2 <- se.n2[rowData(se.n2)$LP == "baseline" & rowData(se.n2)$rep == 1,]

commoncol <- intersect(colnames(colData(se.n1)), colnames(colData(se.n2)))

colData(se.n1) <- colData(se.n1)[,commoncol]
colData(se.n2) <- colData(se.n2)[,commoncol]

rowData(se.n1)$Compound <- "Reference Sol"
rowData(se.n2)$rep <- NULL
rowData(se.n1)$LP <- "baseline"
rowData(se.n1)$column_label <- NULL


commonassays <- intersect(assayNames(se.n2),assayNames(se.n1)) 

assays(se.n2) <- assays(se.n2)[commonassays]
assays(se.n1) <- assays(se.n1)[commonassays]

se.n1$Exp <- "n1"
se.n2$Exp <- "n2"
cd <- rbind(colData(se.n1), colData(se.n2))
rd <- rowData(se.n1)

# Merge assays by column-binding
merged.assays <- lapply(commonassays, function(aname) {
  cbind(assay(se.n1, aname), assay(se.n2, aname))
})
names(merged.assays) <- commonassays


# Create new SummarizedExperiment
se.merged <- SummarizedExperiment(
  assays = SimpleList(merged.assays),
  colData = rbind(colData(se.n1), colData(se.n2)),
  rowData = rowData(se.n1)
)

se.merged <- SingleCellExperiment::SingleCellExperiment(
    assays=assays(se.merged),
    colData=colData(se.merged),
    rowData= rowData(se.merged)
  )

DT::datatable(as.data.frame(colData(se.merged)))
saveRDS(se.merged, "~/dev/r-projects/general/KCNQ2_SMarashili/se.merged_n1-2.rds")

Plotting

metric <- c("CD.peak", "CD.iss", "CD.tail", "CD.decay", "Capacitance")

# melted.df.n1 <- sechm::meltSE(se.n1, features = rownames(se.n1), assayName =metric)
# melted.df.n1$Exp <- "n1"
# melted.df.n2 <- sechm::meltSE(se.n2, features = rownames(se.n2), assayName =metric)
# melted.df.n2$Exp <- "n2"
# melted.df <- rbind(melted.df.n1, melted.df.n2)

melted.df <- sechm::meltSE(se.merged, features = rownames(se.merged), assayName =metric)

#, "X.100mV", "X.20mV"
melted.df <- reshape2::melt(melted.df, measure.vars = metric)#, "CD.iss", "Tail", "Decay"))


melted.df$LP <- factor(melted.df$LP, levels=c("baseline", "treatment", "full.block"))

ggplot(subset(melted.df), aes(V_Clamp, value, color=Celltypes)) +

  stat_summary(geom = 'errorbar', fun.data = mean_se, size = 1, alpha = 0.6) +
  stat_summary(geom = 'line', fun = "mean", size = 1, alpha = 1) +
  theme_minimal(base_size = 16) +
  ylab("Current Density (pA/pF)") +
  xlab("Holding Potential (mV)") +
  geom_hline(yintercept = 0, linetype = "dashed") +
  facet_grid(. ~ variable, scales="free")

qc.summary <- subset(melted.df, V_Clamp == 0 & variable == "CD.peak") %>%
  group_by(Exp, Celltypes) %>%
  summarise(n = n(), 
            Cap_mean = mean(Capacitance_mean, na.rm=T),
            Seal_Mean = mean(Seal_mean, na.rm=T),
            Series_Mean=mean(Series_mean,na.rm=T),
             Cap_min = min(Capacitance_mean, na.rm=T),
            Seal_min = min(Seal_mean, na.rm=T),
            Series_min=min(Series_mean,na.rm=T),
             Cap_max = max(Capacitance_mean, na.rm=T),
            Seal_max = max(Seal_mean, na.rm=T),
            Series_max=max(Series_mean,na.rm=T))

DT::datatable(qc.summary)

Statistics

We used a linear mixed model to fit the different current-density curves and correct for repeated measurments per well as well as random effects from the two experiments. Then we contrasted per voltage step the difference between cell types. General model design:

value ~ as.factor(V_Clamp)*Celltypes + (1|Plate_ID/Well)

Fixed effects
  • Main effect of as.factor(V_Clamp): - These are the baseline IV curve for Celltype1. You see strong significance (p < 0.001) across many clamp steps — expected, since current increases with depolarization.

  • Main effect of Celltypes: The coefficient for Celltype2 (at reference clamp step, here -70 mV) tells you the offset between cell types at baseline. Often not significant — which is fine, because the real differences may only appear at depolarized steps.

  • Interaction terms: These are key. A significant interaction (as.factor(V_Clamp)*Celltypes) means the IV curve shape differs between cell types.

For example, in your CD.peak model, the interaction is significant around +10 and +20 mV (p ~ 0.03). That suggests cell type differences emerge in the depolarized range.

In CD.iss and CD.tail models, you see significance at positive voltages too, with some consistent directional effects.

So the story is: the two cell types don’t differ much at hyperpolarized potentials, but diverge at depolarized voltages.

Current Density Peak

library(lmerTest)
library(emmeans)
library(broom)


mod <- lmer(value ~ as.factor(V_Clamp)*Celltypes + (1|Plate_ID/Well),   subset(melted.df, variable == "CD.peak"))
summary(mod)
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: value ~ as.factor(V_Clamp) * Celltypes + (1 | Plate_ID/Well)
   Data: subset(melted.df, variable == "CD.peak")

REML criterion at convergence: 48275.5

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-9.2123 -0.4358  0.0181  0.3873 15.9855 

Random effects:
 Groups        Name        Variance Std.Dev.
 Well:Plate_ID (Intercept) 139.906  11.828  
 Plate_ID      (Intercept)   1.889   1.374  
 Residual                  140.347  11.847  
Number of obs: 6045, groups:  Well:Plate_ID, 505; Plate_ID, 2

Fixed effects:
                                           Estimate Std. Error         df
(Intercept)                                 1.07446    1.52097    3.43577
as.factor(V_Clamp)-60                      -0.03250    1.17174 5515.23196
as.factor(V_Clamp)-50                       0.43876    1.17174 5515.23196
as.factor(V_Clamp)-40                       1.08185    1.17014 5514.86824
as.factor(V_Clamp)-30                       2.22124    1.17014 5514.86824
as.factor(V_Clamp)-20                       4.89179    1.17174 5515.23196
as.factor(V_Clamp)-10                       9.57713    1.17014 5514.86824
as.factor(V_Clamp)0                        14.84326    1.17014 5514.86824
as.factor(V_Clamp)10                       19.22090    1.17014 5514.86824
as.factor(V_Clamp)20                       22.85157    1.17174 5515.23196
as.factor(V_Clamp)30                       26.15408    1.17014 5514.86824
as.factor(V_Clamp)40                       29.62186    1.17014 5514.86824
CelltypesCelltype2                          0.28004    1.52024 1596.69943
as.factor(V_Clamp)-60:CelltypesCelltype2   -0.05551    1.52044 5515.08426
as.factor(V_Clamp)-50:CelltypesCelltype2   -0.32198    1.52044 5515.08427
as.factor(V_Clamp)-40:CelltypesCelltype2    0.23495    1.51921 5514.86824
as.factor(V_Clamp)-30:CelltypesCelltype2    1.40538    1.51921 5514.86824
as.factor(V_Clamp)-20:CelltypesCelltype2    1.46611    1.52018 5517.11892
as.factor(V_Clamp)-10:CelltypesCelltype2    0.10385    1.51921 5514.86824
as.factor(V_Clamp)0:CelltypesCelltype2     -2.27509    1.51921 5514.86824
as.factor(V_Clamp)10:CelltypesCelltype2    -3.21950    1.51921 5514.86824
as.factor(V_Clamp)20:CelltypesCelltype2    -3.18805    1.52044 5515.08427
as.factor(V_Clamp)30:CelltypesCelltype2    -2.42918    1.51921 5514.86824
as.factor(V_Clamp)40:CelltypesCelltype2    -1.37436    1.51921 5514.86824
                                         t value Pr(>|t|)    
(Intercept)                                0.706   0.5248    
as.factor(V_Clamp)-60                     -0.028   0.9779    
as.factor(V_Clamp)-50                      0.374   0.7081    
as.factor(V_Clamp)-40                      0.925   0.3552    
as.factor(V_Clamp)-30                      1.898   0.0577 .  
as.factor(V_Clamp)-20                      4.175 3.03e-05 ***
as.factor(V_Clamp)-10                      8.185 3.36e-16 ***
as.factor(V_Clamp)0                       12.685  < 2e-16 ***
as.factor(V_Clamp)10                      16.426  < 2e-16 ***
as.factor(V_Clamp)20                      19.502  < 2e-16 ***
as.factor(V_Clamp)30                      22.351  < 2e-16 ***
as.factor(V_Clamp)40                      25.315  < 2e-16 ***
CelltypesCelltype2                         0.184   0.8539    
as.factor(V_Clamp)-60:CelltypesCelltype2  -0.037   0.9709    
as.factor(V_Clamp)-50:CelltypesCelltype2  -0.212   0.8323    
as.factor(V_Clamp)-40:CelltypesCelltype2   0.155   0.8771    
as.factor(V_Clamp)-30:CelltypesCelltype2   0.925   0.3550    
as.factor(V_Clamp)-20:CelltypesCelltype2   0.964   0.3349    
as.factor(V_Clamp)-10:CelltypesCelltype2   0.068   0.9455    
as.factor(V_Clamp)0:CelltypesCelltype2    -1.498   0.1343    
as.factor(V_Clamp)10:CelltypesCelltype2   -2.119   0.0341 *  
as.factor(V_Clamp)20:CelltypesCelltype2   -2.097   0.0361 *  
as.factor(V_Clamp)30:CelltypesCelltype2   -1.599   0.1099    
as.factor(V_Clamp)40:CelltypesCelltype2   -0.905   0.3657    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(mod, trt.vs.ctrl ~ Celltypes | as.factor(V_Clamp), ref="Celltype1")
$emmeans
V_Clamp = -70:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1   1.07 1.52 Inf   -1.9066      4.06
 Celltype2   1.35 1.37 Inf   -1.3347      4.04

V_Clamp = -60:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1   1.04 1.52 Inf   -1.9415      4.03
 Celltype2   1.27 1.37 Inf   -1.4227      3.96

V_Clamp = -50:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1   1.51 1.52 Inf   -1.4702      4.50
 Celltype2   1.47 1.37 Inf   -1.2179      4.16

V_Clamp = -40:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1   2.16 1.52 Inf   -0.8247      5.14
 Celltype2   2.67 1.37 Inf   -0.0179      5.36

V_Clamp = -30:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1   3.30 1.52 Inf    0.3147      6.28
 Celltype2   4.98 1.37 Inf    2.2919      7.67

V_Clamp = -20:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1   5.97 1.52 Inf    2.9828      8.95
 Celltype2   7.71 1.37 Inf    5.0249     10.40

V_Clamp = -10:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1  10.65 1.52 Inf    7.6706     13.63
 Celltype2  11.04 1.37 Inf    8.3463     13.72

V_Clamp =   0:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1  15.92 1.52 Inf   12.9367     18.90
 Celltype2  13.92 1.37 Inf   11.2334     16.61

V_Clamp =  10:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1  20.30 1.52 Inf   17.3143     23.28
 Celltype2  17.36 1.37 Inf   14.6667     20.05

V_Clamp =  20:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1  23.93 1.52 Inf   20.9426     26.91
 Celltype2  21.02 1.37 Inf   18.3288     23.71

V_Clamp =  30:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1  27.23 1.52 Inf   24.2475     30.21
 Celltype2  25.08 1.37 Inf   22.3902     27.77

V_Clamp =  40:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1  30.70 1.52 Inf   27.7153     33.68
 Celltype2  29.60 1.37 Inf   26.9128     32.29

Degrees-of-freedom method: asymptotic 
Confidence level used: 0.95 

$contrasts
V_Clamp = -70:
 contrast              estimate   SE  df z.ratio p.value
 Celltype2 - Celltype1   0.2800 1.52 Inf   0.184  0.8539

V_Clamp = -60:
 contrast              estimate   SE  df z.ratio p.value
 Celltype2 - Celltype1   0.2245 1.52 Inf   0.148  0.8827

V_Clamp = -50:
 contrast              estimate   SE  df z.ratio p.value
 Celltype2 - Celltype1  -0.0419 1.52 Inf  -0.028  0.9780

V_Clamp = -40:
 contrast              estimate   SE  df z.ratio p.value
 Celltype2 - Celltype1   0.5150 1.52 Inf   0.339  0.7348

V_Clamp = -30:
 contrast              estimate   SE  df z.ratio p.value
 Celltype2 - Celltype1   1.6854 1.52 Inf   1.109  0.2676

V_Clamp = -20:
 contrast              estimate   SE  df z.ratio p.value
 Celltype2 - Celltype1   1.7461 1.52 Inf   1.148  0.2508

V_Clamp = -10:
 contrast              estimate   SE  df z.ratio p.value
 Celltype2 - Celltype1   0.3839 1.52 Inf   0.253  0.8006

V_Clamp =   0:
 contrast              estimate   SE  df z.ratio p.value
 Celltype2 - Celltype1  -1.9950 1.52 Inf  -1.312  0.1894

V_Clamp =  10:
 contrast              estimate   SE  df z.ratio p.value
 Celltype2 - Celltype1  -2.9395 1.52 Inf  -1.934  0.0532

V_Clamp =  20:
 contrast              estimate   SE  df z.ratio p.value
 Celltype2 - Celltype1  -2.9080 1.52 Inf  -1.911  0.0560

V_Clamp =  30:
 contrast              estimate   SE  df z.ratio p.value
 Celltype2 - Celltype1  -2.1491 1.52 Inf  -1.414  0.1575

V_Clamp =  40:
 contrast              estimate   SE  df z.ratio p.value
 Celltype2 - Celltype1  -1.0943 1.52 Inf  -0.720  0.4716

Degrees-of-freedom method: asymptotic 
mod.full <- lmer(value ~ as.factor(V_Clamp)*Celltypes + (1|Plate_ID/Well), subset(melted.df, variable == "CD.peak"))
mod.reduced <- lmer(value ~ as.factor(V_Clamp) + (1|Plate_ID/Well), subset(melted.df, variable == "CD.peak"))
anova(mod.reduced, mod.full)
Data: subset(melted.df, variable == "CD.peak")
Models:
mod.reduced: value ~ as.factor(V_Clamp) + (1 | Plate_ID/Well)
mod.full: value ~ as.factor(V_Clamp) * Celltypes + (1 | Plate_ID/Well)
            npar   AIC   BIC logLik -2*log(L)  Chisq Df Pr(>Chisq)  
mod.reduced   15 48368 48469 -24169     48338                       
mod.full      27 48366 48547 -24156     48312 26.212 12    0.01002 *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emm <- emmeans(mod, ~ Celltypes | as.factor(V_Clamp))
contr.peak <- contrast(emm, method = "trt.vs.ctrl") %>% as.data.frame()

plot_iv_curve(mod, melted.df, "CD.peak") + ggtitle("Current-Density at Peak")

Stead-State Current density

mod <- lmer(value ~ as.factor(V_Clamp)*Celltypes + (1|Plate_ID/Well),   subset(melted.df, variable == "CD.iss"))
summary(mod)
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: value ~ as.factor(V_Clamp) * Celltypes + (1 | Plate_ID/Well)
   Data: subset(melted.df, variable == "CD.iss")

REML criterion at convergence: 46869.8

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-8.3319 -0.3555  0.0271  0.3283 13.6166 

Random effects:
 Groups        Name        Variance  Std.Dev. 
 Well:Plate_ID (Intercept) 8.867e+01 9.416e+00
 Plate_ID      (Intercept) 2.242e-18 1.497e-09
 Residual                  1.132e+02 1.064e+01
Number of obs: 6045, groups:  Well:Plate_ID, 505; Plate_ID, 2

Fixed effects:
                                           Estimate Std. Error         df
(Intercept)                                -0.49140    0.99236 1912.42483
as.factor(V_Clamp)-60                      -0.43051    1.05238 5512.43545
as.factor(V_Clamp)-50                      -0.14784    1.05238 5512.43545
as.factor(V_Clamp)-40                       0.55354    1.05096 5511.98740
as.factor(V_Clamp)-30                       1.35881    1.05096 5511.98740
as.factor(V_Clamp)-20                       2.77125    1.05238 5512.43545
as.factor(V_Clamp)-10                       5.49983    1.05096 5511.98740
as.factor(V_Clamp)0                         8.29390    1.05096 5511.98740
as.factor(V_Clamp)10                       11.62233    1.05096 5511.98740
as.factor(V_Clamp)20                       15.92487    1.05238 5512.43545
as.factor(V_Clamp)30                       20.83889    1.05096 5511.98740
as.factor(V_Clamp)40                       27.05029    1.05096 5511.98740
CelltypesCelltype2                          0.15112    1.28823 1914.53144
as.factor(V_Clamp)-60:CelltypesCelltype2    0.20995    1.36557 5512.25352
as.factor(V_Clamp)-50:CelltypesCelltype2   -0.01238    1.36557 5512.25352
as.factor(V_Clamp)-40:CelltypesCelltype2    0.11933    1.36447 5511.98740
as.factor(V_Clamp)-30:CelltypesCelltype2    0.95805    1.36447 5511.98740
as.factor(V_Clamp)-20:CelltypesCelltype2    1.42424    1.36531 5514.31237
as.factor(V_Clamp)-10:CelltypesCelltype2    1.28338    1.36447 5511.98740
as.factor(V_Clamp)0:CelltypesCelltype2      0.95396    1.36447 5511.98740
as.factor(V_Clamp)10:CelltypesCelltype2     1.36070    1.36447 5511.98740
as.factor(V_Clamp)20:CelltypesCelltype2     1.42972    1.36557 5512.25352
as.factor(V_Clamp)30:CelltypesCelltype2     2.79749    1.36447 5511.98740
as.factor(V_Clamp)40:CelltypesCelltype2     3.39813    1.36447 5511.98740
                                         t value Pr(>|t|)    
(Intercept)                               -0.495  0.62053    
as.factor(V_Clamp)-60                     -0.409  0.68250    
as.factor(V_Clamp)-50                     -0.140  0.88829    
as.factor(V_Clamp)-40                      0.527  0.59842    
as.factor(V_Clamp)-30                      1.293  0.19609    
as.factor(V_Clamp)-20                      2.633  0.00848 ** 
as.factor(V_Clamp)-10                      5.233 1.73e-07 ***
as.factor(V_Clamp)0                        7.892 3.57e-15 ***
as.factor(V_Clamp)10                      11.059  < 2e-16 ***
as.factor(V_Clamp)20                      15.132  < 2e-16 ***
as.factor(V_Clamp)30                      19.828  < 2e-16 ***
as.factor(V_Clamp)40                      25.739  < 2e-16 ***
CelltypesCelltype2                         0.117  0.90663    
as.factor(V_Clamp)-60:CelltypesCelltype2   0.154  0.87782    
as.factor(V_Clamp)-50:CelltypesCelltype2  -0.009  0.99277    
as.factor(V_Clamp)-40:CelltypesCelltype2   0.087  0.93031    
as.factor(V_Clamp)-30:CelltypesCelltype2   0.702  0.48262    
as.factor(V_Clamp)-20:CelltypesCelltype2   1.043  0.29692    
as.factor(V_Clamp)-10:CelltypesCelltype2   0.941  0.34697    
as.factor(V_Clamp)0:CelltypesCelltype2     0.699  0.48449    
as.factor(V_Clamp)10:CelltypesCelltype2    0.997  0.31870    
as.factor(V_Clamp)20:CelltypesCelltype2    1.047  0.29516    
as.factor(V_Clamp)30:CelltypesCelltype2    2.050  0.04039 *  
as.factor(V_Clamp)40:CelltypesCelltype2    2.490  0.01279 *  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
optimizer (nloptwrap) convergence code: 0 (OK)
boundary (singular) fit: see help('isSingular')
emmeans(mod, trt.vs.ctrl ~ Celltypes | as.factor(V_Clamp), ref="Celltype1")
$emmeans
V_Clamp = -70:
 Celltypes  emmean    SE  df asymp.LCL asymp.UCL
 Celltype1 -0.4914 0.992 Inf    -2.436      1.45
 Celltype2 -0.3403 0.821 Inf    -1.950      1.27

V_Clamp = -60:
 Celltypes  emmean    SE  df asymp.LCL asymp.UCL
 Celltype1 -0.9219 0.994 Inf    -2.870      1.03
 Celltype2 -0.5608 0.821 Inf    -2.171      1.05

V_Clamp = -50:
 Celltypes  emmean    SE  df asymp.LCL asymp.UCL
 Celltype1 -0.6392 0.994 Inf    -2.587      1.31
 Celltype2 -0.5005 0.821 Inf    -2.110      1.11

V_Clamp = -40:
 Celltypes  emmean    SE  df asymp.LCL asymp.UCL
 Celltype1  0.0621 0.992 Inf    -1.883      2.01
 Celltype2  0.3326 0.821 Inf    -1.277      1.94

V_Clamp = -30:
 Celltypes  emmean    SE  df asymp.LCL asymp.UCL
 Celltype1  0.8674 0.992 Inf    -1.078      2.81
 Celltype2  1.9766 0.821 Inf     0.367      3.59

V_Clamp = -20:
 Celltypes  emmean    SE  df asymp.LCL asymp.UCL
 Celltype1  2.2798 0.994 Inf     0.332      4.23
 Celltype2  3.8552 0.820 Inf     2.247      5.46

V_Clamp = -10:
 Celltypes  emmean    SE  df asymp.LCL asymp.UCL
 Celltype1  5.0084 0.992 Inf     3.063      6.95
 Celltype2  6.4429 0.821 Inf     4.833      8.05

V_Clamp =   0:
 Celltypes  emmean    SE  df asymp.LCL asymp.UCL
 Celltype1  7.8025 0.992 Inf     5.858      9.75
 Celltype2  8.9076 0.821 Inf     7.298     10.52

V_Clamp =  10:
 Celltypes  emmean    SE  df asymp.LCL asymp.UCL
 Celltype1 11.1309 0.992 Inf     9.186     13.08
 Celltype2 12.6427 0.821 Inf    11.033     14.25

V_Clamp =  20:
 Celltypes  emmean    SE  df asymp.LCL asymp.UCL
 Celltype1 15.4335 0.994 Inf    13.486     17.38
 Celltype2 17.0143 0.821 Inf    15.404     18.62

V_Clamp =  30:
 Celltypes  emmean    SE  df asymp.LCL asymp.UCL
 Celltype1 20.3475 0.992 Inf    18.402     22.29
 Celltype2 23.2961 0.821 Inf    21.686     24.91

V_Clamp =  40:
 Celltypes  emmean    SE  df asymp.LCL asymp.UCL
 Celltype1 26.5589 0.992 Inf    24.614     28.50
 Celltype2 30.1081 0.821 Inf    28.498     31.72

Degrees-of-freedom method: asymptotic 
Confidence level used: 0.95 

$contrasts
V_Clamp = -70:
 contrast              estimate   SE  df z.ratio p.value
 Celltype2 - Celltype1    0.151 1.29 Inf   0.117  0.9066

V_Clamp = -60:
 contrast              estimate   SE  df z.ratio p.value
 Celltype2 - Celltype1    0.361 1.29 Inf   0.280  0.7795

V_Clamp = -50:
 contrast              estimate   SE  df z.ratio p.value
 Celltype2 - Celltype1    0.139 1.29 Inf   0.108  0.9143

V_Clamp = -40:
 contrast              estimate   SE  df z.ratio p.value
 Celltype2 - Celltype1    0.270 1.29 Inf   0.210  0.8337

V_Clamp = -30:
 contrast              estimate   SE  df z.ratio p.value
 Celltype2 - Celltype1    1.109 1.29 Inf   0.861  0.3892

V_Clamp = -20:
 contrast              estimate   SE  df z.ratio p.value
 Celltype2 - Celltype1    1.575 1.29 Inf   1.222  0.2215

V_Clamp = -10:
 contrast              estimate   SE  df z.ratio p.value
 Celltype2 - Celltype1    1.435 1.29 Inf   1.114  0.2655

V_Clamp =   0:
 contrast              estimate   SE  df z.ratio p.value
 Celltype2 - Celltype1    1.105 1.29 Inf   0.858  0.3910

V_Clamp =  10:
 contrast              estimate   SE  df z.ratio p.value
 Celltype2 - Celltype1    1.512 1.29 Inf   1.174  0.2406

V_Clamp =  20:
 contrast              estimate   SE  df z.ratio p.value
 Celltype2 - Celltype1    1.581 1.29 Inf   1.226  0.2202

V_Clamp =  30:
 contrast              estimate   SE  df z.ratio p.value
 Celltype2 - Celltype1    2.949 1.29 Inf   2.289  0.0221

V_Clamp =  40:
 contrast              estimate   SE  df z.ratio p.value
 Celltype2 - Celltype1    3.549 1.29 Inf   2.755  0.0059

Degrees-of-freedom method: asymptotic 
emm <- emmeans(mod, ~ Celltypes | as.factor(V_Clamp))
contr.iss <- contrast(emm, method = "trt.vs.ctrl") %>% as.data.frame()

plot_iv_curve(mod, melted.df, "CD.iss") + ggtitle("Current-Density at Steady-state")

Current-Density Tail-Current

mod <- lmer(value ~ as.factor(V_Clamp)*Celltypes + (1|Plate_ID/Well),   subset(melted.df, variable == "CD.tail"))
summary(mod)
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: value ~ as.factor(V_Clamp) * Celltypes + (1 | Plate_ID/Well)
   Data: subset(melted.df, variable == "CD.tail")

REML criterion at convergence: 44761.3

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-9.4925 -0.3447  0.0126  0.3217 17.3057 

Random effects:
 Groups        Name        Variance Std.Dev.
 Well:Plate_ID (Intercept) 239.78   15.48   
 Plate_ID      (Intercept)   0.00    0.00   
 Residual                   71.06    8.43   
Number of obs: 6045, groups:  Well:Plate_ID, 505; Plate_ID, 2

Fixed effects:
                                          Estimate Std. Error        df t value
(Intercept)                                17.5625     1.2314  794.2631  14.262
as.factor(V_Clamp)-60                      -1.2438     0.8338 5514.7782  -1.492
as.factor(V_Clamp)-50                      -1.2546     0.8338 5514.7782  -1.505
as.factor(V_Clamp)-40                      -1.7171     0.8326 5514.6584  -2.062
as.factor(V_Clamp)-30                      -3.1178     0.8326 5514.6584  -3.744
as.factor(V_Clamp)-20                      -5.4257     0.8338 5514.7782  -6.507
as.factor(V_Clamp)-10                      -7.3759     0.8326 5514.6584  -8.858
as.factor(V_Clamp)0                        -8.0897     0.8326 5514.6584  -9.716
as.factor(V_Clamp)10                       -5.1724     0.8326 5514.6584  -6.212
as.factor(V_Clamp)20                       -0.6148     0.8338 5514.7782  -0.737
as.factor(V_Clamp)30                        5.0741     0.8326 5514.6584   6.094
as.factor(V_Clamp)40                       12.0046     0.8326 5514.6584  14.418
CelltypesCelltype2                         -0.1203     1.5981  795.0015  -0.075
as.factor(V_Clamp)-60:CelltypesCelltype2   -0.9396     1.0819 5514.7296  -0.868
as.factor(V_Clamp)-50:CelltypesCelltype2   -3.5410     1.0819 5514.7296  -3.273
as.factor(V_Clamp)-40:CelltypesCelltype2   -5.1250     1.0810 5514.6584  -4.741
as.factor(V_Clamp)-30:CelltypesCelltype2   -4.1546     1.0810 5514.6584  -3.843
as.factor(V_Clamp)-20:CelltypesCelltype2   -2.0905     1.0818 5516.0875  -1.932
as.factor(V_Clamp)-10:CelltypesCelltype2    0.3305     1.0810 5514.6584   0.306
as.factor(V_Clamp)0:CelltypesCelltype2      1.0927     1.0810 5514.6584   1.011
as.factor(V_Clamp)10:CelltypesCelltype2     1.4806     1.0810 5514.6584   1.370
as.factor(V_Clamp)20:CelltypesCelltype2     1.5038     1.0819 5514.7296   1.390
as.factor(V_Clamp)30:CelltypesCelltype2     2.4275     1.0810 5514.6584   2.246
as.factor(V_Clamp)40:CelltypesCelltype2     2.8540     1.0810 5514.6584   2.640
                                         Pr(>|t|)    
(Intercept)                               < 2e-16 ***
as.factor(V_Clamp)-60                    0.135826    
as.factor(V_Clamp)-50                    0.132442    
as.factor(V_Clamp)-40                    0.039236 *  
as.factor(V_Clamp)-30                    0.000183 ***
as.factor(V_Clamp)-20                    8.32e-11 ***
as.factor(V_Clamp)-10                     < 2e-16 ***
as.factor(V_Clamp)0                       < 2e-16 ***
as.factor(V_Clamp)10                     5.61e-10 ***
as.factor(V_Clamp)20                     0.460946    
as.factor(V_Clamp)30                     1.18e-09 ***
as.factor(V_Clamp)40                      < 2e-16 ***
CelltypesCelltype2                       0.940037    
as.factor(V_Clamp)-60:CelltypesCelltype2 0.385163    
as.factor(V_Clamp)-50:CelltypesCelltype2 0.001071 ** 
as.factor(V_Clamp)-40:CelltypesCelltype2 2.18e-06 ***
as.factor(V_Clamp)-30:CelltypesCelltype2 0.000123 ***
as.factor(V_Clamp)-20:CelltypesCelltype2 0.053358 .  
as.factor(V_Clamp)-10:CelltypesCelltype2 0.759826    
as.factor(V_Clamp)0:CelltypesCelltype2   0.312139    
as.factor(V_Clamp)10:CelltypesCelltype2  0.170857    
as.factor(V_Clamp)20:CelltypesCelltype2  0.164609    
as.factor(V_Clamp)30:CelltypesCelltype2  0.024772 *  
as.factor(V_Clamp)40:CelltypesCelltype2  0.008312 ** 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
optimizer (nloptwrap) convergence code: 0 (OK)
boundary (singular) fit: see help('isSingular')
emmeans(mod, trt.vs.ctrl ~ Celltypes | as.factor(V_Clamp), ref="Celltype1")
$emmeans
V_Clamp = -70:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1  17.56 1.23 Inf     15.15      20.0
 Celltype2  17.44 1.02 Inf     15.45      19.4

V_Clamp = -60:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1  16.32 1.23 Inf     13.90      18.7
 Celltype2  15.26 1.02 Inf     13.26      17.3

V_Clamp = -50:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1  16.31 1.23 Inf     13.89      18.7
 Celltype2  12.65 1.02 Inf     10.65      14.6

V_Clamp = -40:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1  15.85 1.23 Inf     13.43      18.3
 Celltype2  10.60 1.02 Inf      8.60      12.6

V_Clamp = -30:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1  14.44 1.23 Inf     12.03      16.9
 Celltype2  10.17 1.02 Inf      8.17      12.2

V_Clamp = -20:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1  12.14 1.23 Inf      9.72      14.6
 Celltype2   9.93 1.02 Inf      7.93      11.9

V_Clamp = -10:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1  10.19 1.23 Inf      7.77      12.6
 Celltype2  10.40 1.02 Inf      8.40      12.4

V_Clamp =   0:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1   9.47 1.23 Inf      7.06      11.9
 Celltype2  10.45 1.02 Inf      8.45      12.4

V_Clamp =  10:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1  12.39 1.23 Inf      9.98      14.8
 Celltype2  13.75 1.02 Inf     11.75      15.7

V_Clamp =  20:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1  16.95 1.23 Inf     14.53      19.4
 Celltype2  18.33 1.02 Inf     16.33      20.3

V_Clamp =  30:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1  22.64 1.23 Inf     20.22      25.1
 Celltype2  24.94 1.02 Inf     22.95      26.9

V_Clamp =  40:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1  29.57 1.23 Inf     27.15      32.0
 Celltype2  32.30 1.02 Inf     30.30      34.3

Degrees-of-freedom method: asymptotic 
Confidence level used: 0.95 

$contrasts
V_Clamp = -70:
 contrast              estimate  SE  df z.ratio p.value
 Celltype2 - Celltype1   -0.120 1.6 Inf  -0.075  0.9400

V_Clamp = -60:
 contrast              estimate  SE  df z.ratio p.value
 Celltype2 - Celltype1   -1.060 1.6 Inf  -0.663  0.5073

V_Clamp = -50:
 contrast              estimate  SE  df z.ratio p.value
 Celltype2 - Celltype1   -3.661 1.6 Inf  -2.290  0.0220

V_Clamp = -40:
 contrast              estimate  SE  df z.ratio p.value
 Celltype2 - Celltype1   -5.245 1.6 Inf  -3.282  0.0010

V_Clamp = -30:
 contrast              estimate  SE  df z.ratio p.value
 Celltype2 - Celltype1   -4.275 1.6 Inf  -2.675  0.0075

V_Clamp = -20:
 contrast              estimate  SE  df z.ratio p.value
 Celltype2 - Celltype1   -2.211 1.6 Inf  -1.383  0.1666

V_Clamp = -10:
 contrast              estimate  SE  df z.ratio p.value
 Celltype2 - Celltype1    0.210 1.6 Inf   0.132  0.8953

V_Clamp =   0:
 contrast              estimate  SE  df z.ratio p.value
 Celltype2 - Celltype1    0.972 1.6 Inf   0.609  0.5428

V_Clamp =  10:
 contrast              estimate  SE  df z.ratio p.value
 Celltype2 - Celltype1    1.360 1.6 Inf   0.851  0.3946

V_Clamp =  20:
 contrast              estimate  SE  df z.ratio p.value
 Celltype2 - Celltype1    1.384 1.6 Inf   0.865  0.3868

V_Clamp =  30:
 contrast              estimate  SE  df z.ratio p.value
 Celltype2 - Celltype1    2.307 1.6 Inf   1.444  0.1488

V_Clamp =  40:
 contrast              estimate  SE  df z.ratio p.value
 Celltype2 - Celltype1    2.734 1.6 Inf   1.711  0.0871

Degrees-of-freedom method: asymptotic 
emm <- emmeans(mod, ~ Celltypes | as.factor(V_Clamp))
contr.tail <- contrast(emm, method = "trt.vs.ctrl") %>% as.data.frame()

plot_iv_curve(mod, melted.df, "CD.tail") + ggtitle("Tail Currents")

Current-Density Tail-Current

mod <- lmer(value ~ as.factor(V_Clamp)*Celltypes + (1|Plate_ID/Well),   subset(melted.df, variable == "CD.decay"))
summary(mod)
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: value ~ as.factor(V_Clamp) * Celltypes + (1 | Plate_ID/Well)
   Data: subset(melted.df, variable == "CD.decay")

REML criterion at convergence: 40753.2

Scaled residuals: 
     Min       1Q   Median       3Q      Max 
-17.8262  -0.3123   0.0032   0.3100  12.5658 

Random effects:
 Groups        Name        Variance Std.Dev.
 Well:Plate_ID (Intercept) 29.578   5.439   
 Plate_ID      (Intercept)  2.046   1.431   
 Residual                  41.246   6.422   
Number of obs: 6045, groups:  Well:Plate_ID, 505; Plate_ID, 2

Fixed effects:
                                           Estimate Std. Error         df
(Intercept)                                 1.57837    1.17013    1.58020
as.factor(V_Clamp)-60                       0.39258    0.63521 5508.65290
as.factor(V_Clamp)-50                       0.58117    0.63521 5508.65290
as.factor(V_Clamp)-40                       0.52830    0.63435 5508.16888
as.factor(V_Clamp)-30                       0.86243    0.63435 5508.16888
as.factor(V_Clamp)-20                       2.11511    0.63521 5508.65290
as.factor(V_Clamp)-10                       4.07731    0.63435 5508.16888
as.factor(V_Clamp)0                         6.54935    0.63435 5508.16888
as.factor(V_Clamp)10                        7.59857    0.63435 5508.16888
as.factor(V_Clamp)20                        6.92127    0.63521 5508.65290
as.factor(V_Clamp)30                        5.31519    0.63435 5508.16888
as.factor(V_Clamp)40                        2.57157    0.63435 5508.16888
CelltypesCelltype2                          0.09512    0.76436 2022.28609
as.factor(V_Clamp)-60:CelltypesCelltype2   -0.26004    0.82424 5508.45640
as.factor(V_Clamp)-50:CelltypesCelltype2   -0.30418    0.82424 5508.45640
as.factor(V_Clamp)-40:CelltypesCelltype2    0.11561    0.82358 5508.16892
as.factor(V_Clamp)-30:CelltypesCelltype2    0.44733    0.82358 5508.16892
as.factor(V_Clamp)-20:CelltypesCelltype2    0.05691    0.82408 5510.52076
as.factor(V_Clamp)-10:CelltypesCelltype2   -1.17952    0.82358 5508.16892
as.factor(V_Clamp)0:CelltypesCelltype2     -3.22905    0.82358 5508.16892
as.factor(V_Clamp)10:CelltypesCelltype2    -4.58020    0.82358 5508.16892
as.factor(V_Clamp)20:CelltypesCelltype2    -4.61235    0.82424 5508.45640
as.factor(V_Clamp)30:CelltypesCelltype2    -5.22667    0.82358 5508.16892
as.factor(V_Clamp)40:CelltypesCelltype2    -4.77249    0.82358 5508.16892
                                         t value Pr(>|t|)    
(Intercept)                                1.349 0.338461    
as.factor(V_Clamp)-60                      0.618 0.536576    
as.factor(V_Clamp)-50                      0.915 0.360266    
as.factor(V_Clamp)-40                      0.833 0.404979    
as.factor(V_Clamp)-30                      1.360 0.174024    
as.factor(V_Clamp)-20                      3.330 0.000875 ***
as.factor(V_Clamp)-10                      6.428 1.41e-10 ***
as.factor(V_Clamp)0                       10.325  < 2e-16 ***
as.factor(V_Clamp)10                      11.979  < 2e-16 ***
as.factor(V_Clamp)20                      10.896  < 2e-16 ***
as.factor(V_Clamp)30                       8.379  < 2e-16 ***
as.factor(V_Clamp)40                       4.054 5.11e-05 ***
CelltypesCelltype2                         0.124 0.900977    
as.factor(V_Clamp)-60:CelltypesCelltype2  -0.315 0.752406    
as.factor(V_Clamp)-50:CelltypesCelltype2  -0.369 0.712113    
as.factor(V_Clamp)-40:CelltypesCelltype2   0.140 0.888366    
as.factor(V_Clamp)-30:CelltypesCelltype2   0.543 0.587046    
as.factor(V_Clamp)-20:CelltypesCelltype2   0.069 0.944950    
as.factor(V_Clamp)-10:CelltypesCelltype2  -1.432 0.152147    
as.factor(V_Clamp)0:CelltypesCelltype2    -3.921 8.93e-05 ***
as.factor(V_Clamp)10:CelltypesCelltype2   -5.561 2.80e-08 ***
as.factor(V_Clamp)20:CelltypesCelltype2   -5.596 2.30e-08 ***
as.factor(V_Clamp)30:CelltypesCelltype2   -6.346 2.38e-10 ***
as.factor(V_Clamp)40:CelltypesCelltype2   -5.795 7.22e-09 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(mod, trt.vs.ctrl ~ Celltypes | as.factor(V_Clamp), ref="Celltype1")
$emmeans
V_Clamp = -70:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1  1.578 1.17 Inf    -0.715      3.87
 Celltype2  1.673 1.12 Inf    -0.527      3.87

V_Clamp = -60:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1  1.971 1.17 Inf    -0.323      4.27
 Celltype2  1.806 1.12 Inf    -0.394      4.01

V_Clamp = -50:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1  2.160 1.17 Inf    -0.135      4.45
 Celltype2  1.950 1.12 Inf    -0.250      4.15

V_Clamp = -40:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1  2.107 1.17 Inf    -0.187      4.40
 Celltype2  2.317 1.12 Inf     0.117      4.52

V_Clamp = -30:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1  2.441 1.17 Inf     0.147      4.73
 Celltype2  2.983 1.12 Inf     0.783      5.18

V_Clamp = -20:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1  3.693 1.17 Inf     1.399      5.99
 Celltype2  3.846 1.12 Inf     1.646      6.05

V_Clamp = -10:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1  5.656 1.17 Inf     3.362      7.95
 Celltype2  4.571 1.12 Inf     2.371      6.77

V_Clamp =   0:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1  8.128 1.17 Inf     5.834     10.42
 Celltype2  4.994 1.12 Inf     2.793      7.19

V_Clamp =  10:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1  9.177 1.17 Inf     6.884     11.47
 Celltype2  4.692 1.12 Inf     2.491      6.89

V_Clamp =  20:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1  8.500 1.17 Inf     6.205     10.79
 Celltype2  3.982 1.12 Inf     1.782      6.18

V_Clamp =  30:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1  6.894 1.17 Inf     4.600      9.19
 Celltype2  1.762 1.12 Inf    -0.438      3.96

V_Clamp =  40:
 Celltypes emmean   SE  df asymp.LCL asymp.UCL
 Celltype1  4.150 1.17 Inf     1.857      6.44
 Celltype2 -0.527 1.12 Inf    -2.728      1.67

Degrees-of-freedom method: asymptotic 
Confidence level used: 0.95 

$contrasts
V_Clamp = -70:
 contrast              estimate    SE  df z.ratio p.value
 Celltype2 - Celltype1   0.0951 0.764 Inf   0.124  0.9010

V_Clamp = -60:
 contrast              estimate    SE  df z.ratio p.value
 Celltype2 - Celltype1  -0.1649 0.765 Inf  -0.216  0.8293

V_Clamp = -50:
 contrast              estimate    SE  df z.ratio p.value
 Celltype2 - Celltype1  -0.2091 0.765 Inf  -0.273  0.7847

V_Clamp = -40:
 contrast              estimate    SE  df z.ratio p.value
 Celltype2 - Celltype1   0.2107 0.764 Inf   0.276  0.7828

V_Clamp = -30:
 contrast              estimate    SE  df z.ratio p.value
 Celltype2 - Celltype1   0.5425 0.764 Inf   0.710  0.4779

V_Clamp = -20:
 contrast              estimate    SE  df z.ratio p.value
 Celltype2 - Celltype1   0.1520 0.765 Inf   0.199  0.8424

V_Clamp = -10:
 contrast              estimate    SE  df z.ratio p.value
 Celltype2 - Celltype1  -1.0844 0.764 Inf  -1.419  0.1560

V_Clamp =   0:
 contrast              estimate    SE  df z.ratio p.value
 Celltype2 - Celltype1  -3.1339 0.764 Inf  -4.100  <.0001

V_Clamp =  10:
 contrast              estimate    SE  df z.ratio p.value
 Celltype2 - Celltype1  -4.4851 0.764 Inf  -5.868  <.0001

V_Clamp =  20:
 contrast              estimate    SE  df z.ratio p.value
 Celltype2 - Celltype1  -4.5172 0.765 Inf  -5.904  <.0001

V_Clamp =  30:
 contrast              estimate    SE  df z.ratio p.value
 Celltype2 - Celltype1  -5.1316 0.764 Inf  -6.713  <.0001

V_Clamp =  40:
 contrast              estimate    SE  df z.ratio p.value
 Celltype2 - Celltype1  -4.6774 0.764 Inf  -6.119  <.0001

Degrees-of-freedom method: asymptotic 
emm <- emmeans(mod, ~ Celltypes | as.factor(V_Clamp))
contr.decay <- contrast(emm, method = "trt.vs.ctrl") %>% as.data.frame()

plot_iv_curve(mod, melted.df, "CD.decay") + ggtitle("Current Decay (Steadystate - Peak)")

Capacitance

Capacitance was averaged across the voltage steps

cap <- subset(melted.df, variable == "Capacitance")
cap <- cap %>% group_by(Plate_ID, Well, Celltypes) %>% summarize(mean_cap = mean(value))

ggplot(cap, aes(Celltypes, y = mean_cap, color=Celltypes, fill=Celltypes))+ geom_boxplot(alpha=0.4) + geom_point() + expand_limits(y=0) + theme_minimal() + ggtitle("Average Capacitance")

mod <- lmer(mean_cap ~ Celltypes + (1|Plate_ID),cap)
summary(mod)
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: mean_cap ~ Celltypes + (1 | Plate_ID)
   Data: cap

REML criterion at convergence: 3435.4

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-3.1421 -0.7015 -0.0910  0.6095  3.6037 

Random effects:
 Groups   Name        Variance Std.Dev.
 Plate_ID (Intercept)  0.1917  0.4378  
 Residual             54.3804  7.3743  
Number of obs: 503, groups:  Plate_ID, 2

Fixed effects:
                   Estimate Std. Error       df t value Pr(>|t|)    
(Intercept)         25.5800     0.6023   3.1201   42.47 2.05e-05 ***
CelltypesCelltype2  -8.4658     0.6709 499.8817  -12.62  < 2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Correlation of Fixed Effects:
            (Intr)
ClltypsCll2 -0.662
emmeans(mod, trt.vs.ctrl ~ Celltypes, ref="Celltype1")
$emmeans
 Celltypes emmean    SE   df lower.CL upper.CL
 Celltype1   25.6 0.604 3.12     23.7     27.5
 Celltype2   17.1 0.529 1.83     14.6     19.6

Degrees-of-freedom method: kenward-roger 
Confidence level used: 0.95 

$contrasts
 contrast              estimate    SE  df t.ratio p.value
 Celltype2 - Celltype1    -8.47 0.676 500 -12.517  <.0001

Degrees-of-freedom method: kenward-roger