May 30, 2016
head(dta[,1:6],5)
Subject Channel Condition IQ Time1 Time2 1 Sub1 Channel_1 L 74 9.41547e-07 5.66481e-07 2 Sub1 Channel_2 L 74 4.76202e-07 1.33424e-07 3 Sub1 Channel_3 L 74 6.23525e-07 4.88530e-07 4 Sub1 Channel_4 L 74 8.10356e-07 5.98575e-07 5 Sub1 Channel_5 L 74 7.50515e-07 5.26700e-07
tail(dta[,1:6],5)
Subject Channel Condition IQ Time1 Time2 396 Sub20 Channel_6 H 130 -1.04115e-06 -1.05311e-06 397 Sub20 Channel_7 H 130 -1.39371e-07 -6.96321e-07 398 Sub20 Channel_8 H 130 -1.60774e-07 -1.26477e-07 399 Sub20 Channel_9 H 130 -6.81029e-08 1.82143e-07 400 Sub20 Channel_10 H 130 2.39154e-07 3.43515e-07
str(dta[,1:7],digits.d=1)
'data.frame': 400 obs. of 7 variables: $ Subject : Factor w/ 20 levels "Sub1","Sub2",..: 1 1 1 1 1 1 1 1 1 1 ... $ Channel : Factor w/ 10 levels "Channel_1","Channel_2",..: 1 2 3 4 5 6 7 8 9 10 ... $ Condition: Factor w/ 2 levels "L","H": 1 1 1 1 1 1 1 1 1 1 ... $ IQ : num 74 74 74 74 74 ... $ Time1 : num 9e-07 5e-07 6e-07 8e-07 8e-07 ... $ Time2 : num 6e-07 1e-07 5e-07 6e-07 5e-07 ... $ Time3 : num -3e-07 -4e-07 1e-07 2e-07 3e-07 ...
timepoint <- seq(-2,14.96,by=0.16)
Fig0 <- edaplot(data = dta,
frames = timepoint ,
datacol=5:111,
subjcol=1,
chancol=2,
othvarcol=3:4)+
geom_line(aes(col=Condition))+
facet_grid(Channel~Subject)
timepoint <- seq(-2,14.96,by=0.16)
Fig1 <- edaplot(data = dta,
frames = timepoint ,
datacol=5:110,
subjcol=1,
chancol=2,
othvarcol=c(3,4),
select_subj = c("Sub7","Sub10","Sub12"),
select_chan = c("Channel_2","Channel_3"))+
geom_line(aes(col=Condition))+
facet_grid(Channel~Subject)+
theme_bw()
Fig2 <- edaplot(data = dta,frames = timepoint ,
datacol=5:111,subjcol=1,chancol=2,othvarcol=c(3,4),
outlinesub = "Sub7",outcolor = "red",
select_chan = c("Channel_1","Channel_2",
"Channel_3","Channel_4"))+
facet_grid(.~Channel)+theme_bw()
Fig3 <- edaplot(data = dta,frames = timepoint ,
datacol=5:111,subjcol=1,chancol=2,othvarcol=c(3,4),
outlinesub = "Sub10",outcolor = "green",
select_chan = c("Channel_1","Channel_2",
"Channel_3","Channel_4"))+
facet_grid(.~Channel)+theme_bw()
Fig4 <- edaplot(data = dta,frames = timepoint ,
datacol=5:111,subjcol=1,chancol=2,othvarcol=c(3,4),
outlinesub = "Sub12",outcolor = "blue",
select_chan = c("Channel_1","Channel_2",
"Channel_3","Channel_4"))+
facet_grid(.~Channel)+theme_bw()
dta2 <- data_select(data = dta,frames = timepoint ,
datacol=5:111,subjcol=1,
chancol=2,othvarcol=3:4,
select_subj = c(paste("Sub",
c(1:6,8:9,11,13:20),sep="")))
head(dta2[,1:6],3)
Subject Channel Condition IQ Time1 Time2 1 Sub1 Channel_1 L 74 9.41547e-07 5.66481e-07 2 Sub1 Channel_2 L 74 4.76202e-07 1.33424e-07 3 Sub1 Channel_3 L 74 6.23525e-07 4.88530e-07
dim(dta2)
[1] 340 111
dta3 <- downsample(data = dta2,
datacol = 5:111,
binwidth = 10,
movinginterval=5)
timepoint2 <- seq(-2,14.96,by = 0.6525)
Fig5 <- edaplot(data = dta3,frames = timepoint2 ,
datacol= 5:30,subjcol=1,
chancol=2,othvarcol=3:4)+
geom_line(aes(col=Subject))+
facet_wrap(~Channel)
Fig6 <- edaplot(data = dta3,frames = timepoint2,
datacol= 4:29,subjcol=1,chancol=2,othvarcol=3:4)+
geom_line(aes(col=IQ))+
facet_grid(Condition~Channel)
Fig7 <- edaplot(data = dta3,frames = timepoint2,
datacol= 4:29,subjcol=1,
chancol=2,othvarcol=3:4)+
geom_line(aes(col=Condition))+
facet_wrap(~Channel)
Fig8 <- Fig7+
stat_summary(aes(group=Condition,shape=Condition),
fun.y = "mean",col = "blue",
geom = "point",size =1.5)+
theme_bw()+
theme(legend.position=c(0.8,0.15))+
labs(list(x="Time Points",y="Signal"))
dtasum <- data_summarize(data=dta3,
frames = timepoint2,
datacol = 5:30,
subjcol = 1,
chancol = 2,
othvarcol = 3:4,
summarycol= c(2,3),
fun=mean)
head(dtasum[,c(1:5)])
Channel Condition value.1 value.2 value.3 1 Channel_1 L -1.898317e-07 1.902874e-07 7.609002e-07 2 Channel_2 L -4.462120e-08 -3.553222e-09 3.033979e-07 3 Channel_3 L -9.023315e-09 -5.554516e-08 1.806674e-07 4 Channel_4 L -7.345304e-08 -1.542970e-08 3.596421e-07 5 Channel_5 L -3.494380e-08 -4.848521e-09 2.369591e-07 6 Channel_6 L 3.810523e-08 -7.817846e-08 1.162215e-07
Fig9 <- edaplot(data = dtasum,
frames = timepoint2 ,
datacol= 3:28,
#subjcol=NULL,
chancol=1,
othvarcol=2)+
geom_line(aes(col=Condition))+
facet_wrap(~Channel)
Fig10 <- Fig9+
scale_color_manual(values= c("blue","red"))+
facet_wrap(~Channel)+
theme_bw()+
theme(legend.position=c(0.8,0.15))+
labs(list(title="Average HRF curve",
x="Time Points",y="Signal"))
Fig11 <- edaplot(data = dta,
frames = timepoint <- seq(-2,14.96,by=0.16),
datacol=5:30,subjcol=1,chancol=2,
othvarcol=3:4,
select_subj = "Sub18",select_chan = "Channel_5")+
theme_bw()+theme(legend.position=c(0.075,0.15),
legend.key.size =unit(0.3, "cm"),
legend.title = element_text(size=8),
legend.key = element_rect(colour = "black"))+
labs(list(title="Channel5 : Average HRF curve",
x="Time Points",y="Signal"))+
geom_rect(xmin=0, xmax=5, ymin=-Inf, ymax=+Inf,
alpha =0.1,fill="grey95")+
geom_line(aes(col=Condition))+
scale_color_manual(values = c("black","grey70"))
Let's look forward to further introdiction in "project presenation" next time !