Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

R

6600 views
Kernel: R
options(jupyter.plot_mimetypes = 'image/png')

Exercise 1

?read.table()
  • Both .csv and .txt function can be used to load spreadsheets into R

.txt

  • .txt (for files that are delimited by tabs) can be loaded in following way:

    dataframe <- read.table("<FileName>.txt", header = FALSE)
    • data from the file will become a data.frame object

    • the first argument isn't always a filename, but could possibly also be a webpage that contains data.

    • The header argument specifies whether or not you have specified column names in your data file.

.csv

  • .csv (for files that are not delimited by tabs, instead by separators)

    dataframe <- read.table("<FileName>.cvs", header = FALSE)
  • .csv differs from .txt by: * The separator symbol * The header argument is always set at TRUE, which indicates that the first line of the file being read contains the header with the variable names * The fill argument is also set as TRUE, which means that if rows have unequal length, blank fields will be added implicitly.

  • Overall clarity (score = 0.25)

  • Correctness of the code (score = 0.25)

  • Exhaustive cover of required analysis (score= 0.25)

  • Interpretation of the results (score = 0.25)

  • Total Score = 1

Exercise 2

data <- read.csv("data_wk3/smokers.csv", header = TRUE) data
Smokers..mmHg. Non.smokers..mmHg. 1 1.03000e+02 107 2 1.14000e+02 101 3 1.25000e+02 103 4 1.18000e+02 95 5 1.19000e+02 101 6 1.28000e+02 98 7 1.10000e+02 112 8 9.80000e+01 98 9 1.25000e+02 106 10 1.34000e+02 113 11 1.11000e+02 102 12 1.14000e+02 114 13 1.15000e+02 101 14 1.12000e+02 94 15 NA 16 NA 17 NA 18 3.05975e-04 equal 19 3.89071e-04 unequal
str(data)
'data.frame': 19 obs. of 2 variables: $ Smokers..mmHg. : num 103 114 125 118 119 128 110 98 125 134 ... $ Non.smokers..mmHg.: Factor w/ 14 levels "","101","102",..: 6 2 4 11 2 12 7 12 5 8 ...

The str() command tells that there are 19 observations and 2 variables. ie 19 rows and 2 variables.

"$Smokers..mmHg" lists the numerical vectors of the comlumn.

"$Non.smokers..mmHg" tells that the second last row in the column caused problem to create numerical vectors.

  • Overall clarity (score = 0.25)

  • Correctness of the code (score = 0.25)

  • Exhaustive cover of required analysis (score= 0.25)

  • Interpretation of the results (score = 0.25)

  • Total Score = 1

Explain a solution for missing data, is.na()

Exercise 3

  • As R reads the data, R will classify the variables into types:

    • Columns with only numbers are made into numeric or integer variables.

    • Columns with non-numeric characters are made into factors unless you specify that they should remain characters using the stringsAsFactors = FALSE option in the read command.

  • A factor is a categorical variable whose categories represent levels. These levels are named, like characters, but the levels additionally have a numerical interpretation. It is easy to convert character data to factors later, when you need them.

** In the smokers data, the strings equal and unequal in column 2 can possibly add extra numerical value in data analysis later, inducing inaccuracy. ** Two methods were suggested in Exercise 4 to overcome this.

  • First, to eliminate the last two rows completely by choosing only the first 14 rows

  • Second, to replace the strings with NA

  • Overall clarity (score = 0.25)

  • Correctness of the code (score = 0.25)

  • Exhaustive cover of required analysis (score= 0.25)

  • Interpretation of the results (score = 0.25)

  • Total Score = 1

Exercise 4

data1 <- read.csv("data_wk3/smokers.csv", header = TRUE, nrows=14) data1
Smokers..mmHg. Non.smokers..mmHg. 1 103 107 2 114 101 3 125 103 4 118 95 5 119 101 6 128 98 7 110 112 8 98 98 9 125 106 10 134 113 11 111 102 12 114 114 13 115 101 14 112 94
cleandata1 <- read.csv("data_wk3/smokers.csv", header = TRUE, nrows = 17) cleandata1
Smokers..mmHg. Non.smokers..mmHg. 1 103 107 2 114 101 3 125 103 4 118 95 5 119 101 6 128 98 7 110 112 8 98 98 9 125 106 10 134 113 11 111 102 12 114 114 13 115 101 14 112 94 15 NA NA 16 NA NA 17 NA NA
cleandata2 <- read.csv("data_wk3/smokers.csv", header = TRUE, na.strings=c("equal","unequal")) cleandata2
Smokers..mmHg. Non.smokers..mmHg. 1 1.03000e+02 107 2 1.14000e+02 101 3 1.25000e+02 103 4 1.18000e+02 95 5 1.19000e+02 101 6 1.28000e+02 98 7 1.10000e+02 112 8 9.80000e+01 98 9 1.25000e+02 106 10 1.34000e+02 113 11 1.11000e+02 102 12 1.14000e+02 114 13 1.15000e+02 101 14 1.12000e+02 94 15 NA NA 16 NA NA 17 NA NA 18 3.05975e-04 NA 19 3.89071e-04 NA
write.csv(cleandata2,file="smokers_clean.csv")
  • Overall clarity (score = 0.25)

  • Correctness of the code (score = 0.25)

  • Exhaustive cover of required analysis (score= 0.25)

  • Interpretation of the results (score = 0.25)

  • Total Score = 1

Exercise 5

smokers1<-data$Smokers..mmHg. nonsmokers1<-cleandata2$Non.smokers..mmHg. smokers1 nonsmokers1
[1] 1.03000e+02 1.14000e+02 1.25000e+02 1.18000e+02 1.19000e+02 1.28000e+02 [7] 1.10000e+02 9.80000e+01 1.25000e+02 1.34000e+02 1.11000e+02 1.14000e+02 [13] 1.15000e+02 1.12000e+02 NA NA NA 3.05975e-04 [19] 3.89071e-04
[1] 107 101 103 95 101 98 112 98 106 113 102 114 101 94 NA NA NA NA NA
DescriptiveStatistics=function(x){ Avg<-mean(x) Med<-median(x) Q1<-quantile(x,prob=0.25) Q2<-quantile(x,prob=0.5) Q3<-quantile(x,prob=0.75) Min<-min(x) Max<-max(x) SD<-sd(x) Var<-var(x) A<-c(Avg,Med,Q1,Q2,Q3,Min,Max,SD,Var) return(A) } Label=c("Mean","Median","Q1","Q2","Q3","Minimum","Maximum","SD","Variance") x=data.frame(Label,DescriptiveStatistics(smokers1),DescriptiveStatistics(nonsmokers1)) colnames(x)=c("Data","Smokers(mmHg)","Non-smokers(mmHg)") x
Error in quantile.default(x, prob = 0.25): missing values and NaN's not allowed if 'na.rm' is FALSE Traceback: 1. data.frame(Label, DescriptiveStatistics(smokers1), DescriptiveStatistics(nonsmokers1)) 2. DescriptiveStatistics(smokers1) 3. quantile(x, prob = 0.25) # at line 4 of file <text> 4. quantile.default(x, prob = 0.25) 5. stop("missing values and NaN's not allowed if 'na.rm' is FALSE")

**INSTRUCTOR Feedback:**How would you solve this problem? See solutions for some ideas.

smokers<-data1$Smokers..mmHg. nonsmokers<-data1$Non.smokers..mmHg. smokers nonsmokers
[1] 103 114 125 118 119 128 110 98 125 134 111 114 115 112
[1] 107 101 103 95 101 98 112 98 106 113 102 114 101 94
DescriptiveStatistics=function(x){ Avg<-mean(x) Med<-median(x) Q1<-quantile(x,prob=0.25) Q2<-quantile(x,prob=0.5) Q3<-quantile(x,prob=0.75) Min<-min(x) Max<-max(x) SD<-sd(x) Var<-var(x) A<-c(Avg,Med,Q1,Q2,Q3,Min,Max,SD,Var) return(A) } Label=c("Mean","Median","Q1","Q2","Q3","Minimum","Maximum","SD","Variance") x=data.frame(Label,DescriptiveStatistics(smokers),DescriptiveStatistics(nonsmokers)) colnames(x)=c("Data","Smokers(mmHg)","Non-smokers(mmHg)") x
Data Smokers(mmHg) Non-smokers(mmHg) 1 Mean 116.142857 103.214286 2 Median 114.500000 101.500000 3 Q1 111.250000 98.750000 4 Q2 114.500000 101.500000 5 Q3 123.500000 106.750000 6 Minimum 98.000000 94.000000 7 Maximum 134.000000 114.000000 8 SD 9.694226 6.411271 9 Variance 93.978022 41.104396

** Clean data**

smokers2 <- cleandata2$Smokers..mmHg. nonsmokers2 <- cleandata2$Non.smokers..mmHg. smokers2 nonsmokers2
[1] 1.03000e+02 1.14000e+02 1.25000e+02 1.18000e+02 1.19000e+02 1.28000e+02 [7] 1.10000e+02 9.80000e+01 1.25000e+02 1.34000e+02 1.11000e+02 1.14000e+02 [13] 1.15000e+02 1.12000e+02 NA NA NA 3.05975e-04 [19] 3.89071e-04
[1] 107 101 103 95 101 98 112 98 106 113 102 114 101 94 NA NA NA NA NA
smokers1[is.na(smokers1)] <- 0 smokers1 nonsmokers1[is.na(nonsmokers1)] <- 0 nonsmokers1
[1] 1.03000e+02 1.14000e+02 1.25000e+02 1.18000e+02 1.19000e+02 1.28000e+02 [7] 1.10000e+02 9.80000e+01 1.25000e+02 1.34000e+02 1.11000e+02 1.14000e+02 [13] 1.15000e+02 1.12000e+02 0.00000e+00 0.00000e+00 0.00000e+00 3.05975e-04 [19] 3.89071e-04
[1] 107 101 103 95 101 98 112 98 106 113 102 114 101 94 0 0 0 0 0

** With missing values **

DescriptiveStatistics=function(x){ Avg<-mean(x) Med<-median(x) Q1<-quantile(x,prob=0.25) Q2<-quantile(x,prob=0.5) Q3<-quantile(x,prob=0.75) Min<-min(x) Max<-max(x) SD<-sd(x) Var<-var(x) A<-c(Avg,Med,Q1,Q2,Q3,Min,Max,SD,Var) return(A) } Label=c("Mean","Median","Q1","Q2","Q3","Minimum","Maximum","SD","Variance") x=data.frame(Label,DescriptiveStatistics(smokers1),DescriptiveStatistics(nonsmokers1)) colnames(x)=c("Data","Smokers(mmHg)","Non-smokers(mmHg)") x
Data Smokers(mmHg) Non-smokers(mmHg) 1 Mean 85.57898 76.05263 2 Median 112.00000 101.00000 3 Q1 49.00019 47.00000 4 Q2 112.00000 101.00000 5 Q3 118.50000 104.50000 6 Minimum 0.00000 0.00000 7 Maximum 134.00000 114.00000 8 SD 53.18652 47.01238 9 Variance 2828.80626 2210.16374
DescriptiveStatistics=function(x){ x[is.na(x)] <- 0 x Avg<-mean(x) Med<-median(x) Q1<-quantile(x,prob=0.25) Q2<-quantile(x,prob=0.5) Q3<-quantile(x,prob=0.75) Min<-min(x) Max<-max(x) SD<-sd(x) Var<-var(x) A<-c(Avg,Med,Q1,Q2,Q3,Min,Max,SD,Var) return(A) } Label=c("Mean","Median","Q1","Q2","Q3","Minimum","Maximum","SD","Variance") x=data.frame(Label,DescriptiveStatistics(smokers2),DescriptiveStatistics(nonsmokers2)) colnames(x)=c("Data","Smokers_cleandata2(mmHg)","Non-smokers_cleandata2(mmHg)") x
Data Smokers_cleandata2(mmHg) Non-smokers_cleandata2(mmHg) 1 Mean 85.57898 76.05263 2 Median 112.00000 101.00000 3 Q1 49.00019 47.00000 4 Q2 112.00000 101.00000 5 Q3 118.50000 104.50000 6 Minimum 0.00000 0.00000 7 Maximum 134.00000 114.00000 8 SD 53.18652 47.01238 9 Variance 2828.80626 2210.16374

** Without missing values **

DescriptiveStatistics=function(x){ Avg<-mean(x, na.rm=TRUE) Med<-median(x, na.rm=TRUE) Q1<-quantile(x,prob=0.25, na.rm=TRUE) Q2<-quantile(x,prob=0.5, na.rm=TRUE) Q3<-quantile(x,prob=0.75, na.rm=TRUE) Min<-min(x, na.rm=TRUE) Max<-max(x ,na.rm=TRUE) SD<-sd(x,na.rm=TRUE) Var<-var(x,na.rm=TRUE) A<-c(Avg,Med,Q1,Q2,Q3,Min,Max,SD,Var) return(A) } Label=c("Mean","Median","Q1","Q2","Q3","Minimum","Maximum","SD","Variance") x=data.frame(Label, DescriptiveStatistics(smokers2),DescriptiveStatistics(nonsmokers2)) colnames(x)=c("Data","Smokers_cleandata2(mmHg)","Non-smokers_cleandata2(mmHg)") x
Data Smokers_cleandata2(mmHg) Non-smokers_cleandata2(mmHg) 1 Mean 1.016250e+02 103.214286 2 Median 1.140000e+02 101.500000 3 Q1 1.082500e+02 98.750000 4 Q2 1.140000e+02 101.500000 5 Q3 1.205000e+02 106.750000 6 Minimum 3.059750e-04 94.000000 7 Maximum 1.340000e+02 114.000000 8 SD 4.068383e+01 6.411271 9 Variance 1.655174e+03 41.104396
par(mfrow=c(3,2)) hist(smokers1, prob=F, main='Smokers_data', xlab="Blood Pressure(mmHg)", ylab='Number of Smokers') par(fg='black') abline(v=mean(smokers1), col=rgb(0.5,0.5,0.5)) abline(v=median(smokers1), lty=3, col=rgb(0.5,0.5,0.5)) abline(v=mean(smokers1)+sd(smokers1), lty=2, col=rgb(0.7,0.7,0.7)) abline(v=mean(smokers1)-sd(smokers1), lty=2, col=rgb(0.7,0.7,0.7)) hist(nonsmokers1, prob=F, main='Non-smokers_data', xlab="Blood Pressure(mmHg)", ylab='Number of Non-smokers') par(fg='black') abline(v=mean(nonsmokers1), col=rgb(0.5,0.5,0.5)) abline(v=median(nonsmokers1), lty=3, col=rgb(0.5,0.5,0.5)) abline(v=mean(nonsmokers1)+sd(nonsmokers1), lty=2, col=rgb(0.7,0.7,0.7)) abline(v=mean(nonsmokers1)-sd(nonsmokers1), lty=2, col=rgb(0.7,0.7,0.7)) hist(smokers2, prob=F, main='Smokers_cleandata2', xlab="Blood Pressure(mmHg)", ylab='Number of Smokers') par(fg='black') abline(v=mean(smokers2,na.rm=TRUE), col=rgb(0.5,0.5,0.5)) abline(v=median(smokers2,na.rm=TRUE), lty=3, col=rgb(0.5,0.5,0.5)) abline(v=mean(smokers2,na.rm=TRUE)+sd(smokers2,na.rm=TRUE), lty=2, col=rgb(0.7,0.7,0.7)) abline(v=mean(smokers2,na.rm=TRUE)-sd(smokers2,na.rm=TRUE), lty=2, col=rgb(0.7,0.7,0.7)) hist(nonsmokers2, prob=F, main='Non-smokers_cleandata2', xlab="Blood Pressure(mmHg)", ylab='Number of Non-smokers') par(fg='black') abline(v=mean(nonsmokers2,na.rm=TRUE), col=rgb(0.5,0.5,0.5)) abline(v=median(nonsmokers2,na.rm=TRUE), lty=3, col=rgb(0.5,0.5,0.5)) abline(v=mean(nonsmokers2,na.rm=TRUE)+sd(nonsmokers2,na.rm=TRUE), lty=2, col=rgb(0.7,0.7,0.7)) abline(v=mean(nonsmokers2,na.rm=TRUE)-sd(nonsmokers2,na.rm=TRUE), lty=2, col=rgb(0.7,0.7,0.7))
Image in a Jupyter notebook
  • The histograms allowed better visualization of the shift of central tendency(mean, median)and the spread of blood pressure between (smokers and non-smokers) and also groups(with missing values and without missing values).

  • The histogram of smokers without missing values has mean+median shifted to the right, ie effect of the data from last two rows + NA.

  • The histogram of non-smokers without missing values has mean+median shifted to he left and that the shape went from bimodal to normal distribution. This is caused by the strings in last 2 rows of data + NA.

WithMissingValues<-t.test(smokers1,nonsmokers1) WithoutMissingValues<-t.test(smokers2, nonsmokers2) P_values<-c(WithMissingValues$p.value,WithoutMissingValues$p.value) Smoker_TTest<-matrix(P_values,nrow=2,ncol=1) Smoker_TTest
[,1] [1,] 0.0003890707 [2,] 0.8794902595
The p-values of data with and without the missing
  • Overall clarity (score = 0.25)

  • Correctness of the code (score = 0.25)

  • Exhaustive cover of required analysis (score= 0.25)

  • Interpretation of the results (score = 0.25)

  • Total Score = 1

log2(cleandata2)
Smokers..mmHg. Non.smokers..mmHg. 1 6.686501 6.741467 2 6.832890 6.658211 3 6.965784 6.686501 4 6.882643 6.569856 5 6.894818 6.658211 6 7.000000 6.614710 7 6.781360 6.807355 8 6.614710 6.614710 9 6.965784 6.727920 10 7.066089 6.820179 11 6.794416 6.672425 12 6.832890 6.832890 13 6.845490 6.658211 14 6.807355 6.554589 15 NA NA 16 NA NA 17 NA NA 18 -11.674299 NA 19 -11.327679 NA
A = c(log2(cleandata2)) A
$Smokers..mmHg. [1] 6.686501 6.832890 6.965784 6.882643 6.894818 7.000000 [7] 6.781360 6.614710 6.965784 7.066089 6.794416 6.832890 [13] 6.845490 6.807355 NA NA NA -11.674299 [19] -11.327679 $Non.smokers..mmHg. [1] 6.741467 6.658211 6.686501 6.569856 6.658211 6.614710 6.807355 6.614710 [9] 6.727920 6.820179 6.672425 6.832890 6.658211 6.554589 NA NA [17] NA NA NA
b = c(A$Smokers..mmHg.) c = c(A$Non.smokers..mmHg.) b c
[1] 6.686501 6.832890 6.965784 6.882643 6.894818 7.000000 [7] 6.781360 6.614710 6.965784 7.066089 6.794416 6.832890 [13] 6.845490 6.807355 NA NA NA -11.674299 [19] -11.327679
[1] 6.741467 6.658211 6.686501 6.569856 6.658211 6.614710 6.807355 6.614710 [9] 6.727920 6.820179 6.672425 6.832890 6.658211 6.554589 NA NA [17] NA NA NA
densityplot(~ smokers2, plot.points = FALSE, auto.key = TRUE)
Error in eval(expr, envir, enclos): object 'smokers2' not found Traceback: 1. densityplot(~smokers2, plot.points = FALSE, auto.key = TRUE) 2. densityplot.formula(~smokers2, plot.points = FALSE, auto.key = TRUE) 3. latticeParseFormula(formula, data, subset = subset, groups = groups, . multiple = allow.multiple, outer = outer, subscripts = TRUE, . drop = drop.unused.levels) 4. eval(varsRHS[[1]], data, env) 5. eval(expr, envir, enclos)
plot(density(smokers2, na.rm=TRUE), col="yellow") lines(density(smokers2,na.rm=TRUE,adjust=1), xlim=c(-10,150),ylim=c(0,0.1), col="yellow") points(density(nonsmokers2, na.rm=TRUE), col="green") lines(density(nonsmokers2,na.rm=TRUE,adjust=1), col="green") points(density(c, na.rm=TRUE), col="blue") lines(density(c,na.rm=TRUE,adjust=1), col="blue") points(density(b, na.rm=TRUE), col="black") lines(density(b,na.rm=TRUE,adjust=1), col="black") O<- density(smokers2,na.rm=TRUE) P<- density(nonsmokers2,na.rm=TRUE) Q<- density(c,na.rm=TRUE) R<- density(d,na.rm=TRUE) plot(O,col="yellow", xlim=c(min(O$x,P$x,Q$x,R$x),max(O$x,P$x,Q$x,R$x)),ylim=c(min(O$x,P$x,Q$x,R$x),max(O$x,P$x,Q$x,R$x))) points(P,col="green") points(Q,col="blue") points(R,col="black")
Error in density.default(d, na.rm = TRUE): argument 'x' must be numeric Traceback: 1. density(d, na.rm = TRUE) 2. density.default(d, na.rm = TRUE) 3. stop("argument 'x' must be numeric")
Image in a Jupyter notebook
  • With the log transformation (blue and black), the range of BP is scaled down compared to pre-log transsformation(yellow and green)

  • Overall clarity (score = 0.25)

  • Correctness of the code (score = 0)

  • Exhaustive cover of required analysis (score= 0.25)

  • Interpretation of the results (score = 0.25)

  • Total Score = 0.75

INSTRUCTOR Feedback: You need to resolvethe errors when they happen. I have not run the notebook again but you can check whether the correct way of implementing this is min(c(O$x,P$x,Q$x,R$x)) which will give you the min of all those values. Same for max.

Exercise 7

  • Overall clarity (score = 0)

  • Correctness of the code (score = 0)

  • Exhaustive cover of required analysis (score= 0)

  • Interpretation of the results (score = 0)

  • Total Score = 0

LOGDATA<-log2(cleandata2) LOGDATA b <- LOGDATA$Smokers..mmHg. b a <- LOGDATA$Non.smokers..mmHg. a
Smokers..mmHg. Non.smokers..mmHg. 1 6.686501 6.741467 2 6.832890 6.658211 3 6.965784 6.686501 4 6.882643 6.569856 5 6.894818 6.658211 6 7.000000 6.614710 7 6.781360 6.807355 8 6.614710 6.614710 9 6.965784 6.727920 10 7.066089 6.820179 11 6.794416 6.672425 12 6.832890 6.832890 13 6.845490 6.658211 14 6.807355 6.554589 15 NA NA 16 NA NA 17 NA NA 18 -11.674299 NA 19 -11.327679 NA
[1] 6.686501 6.832890 6.965784 6.882643 6.894818 7.000000 [7] 6.781360 6.614710 6.965784 7.066089 6.794416 6.832890 [13] 6.845490 6.807355 NA NA NA -11.674299 [19] -11.327679
[1] 6.741467 6.658211 6.686501 6.569856 6.658211 6.614710 6.807355 6.614710 [9] 6.727920 6.820179 6.672425 6.832890 6.658211 6.554589 NA NA [17] NA NA NA

M=log2(X)−log2(Y) A=0.5(log2(x)+log2(y))

library(lattice) mat <- LOGDATA[,1:2] A <- 0.5(log2(x)+log2(y)) M <- log2(x) log2(y) Sample <- rep(colnames(LOGDATA), each=nrow(LOGDATA)) df <- data.frame(LOGDATA,Sample, row.names=NULL, check.names = FALSE, na.rm=TRUE) plt <- xyplot(M ~ A | Sample, df, panel=panel.smoothScatter)
Error in parse(text = x, srcfile = src): <text>:4:13: unexpected input 3: A <- 0.5(log2(x)+log2(y)) 4: M <- log2(x) <e2> ^ Traceback:
library(lattice) mat <- exprsMat[,1:20] A <- rowMeans(log2(mat)) M <- log2(unlist(mat)) - A Sample <- rep(colnames(mat), each=nrow(mat)) df <- data.frame(M, A, Sample, row.names=NULL, check.names = FALSE) plt <- xyplot(M ~ A | Sample, df, panel=panel.smoothScatter)
Error in eval(substitute(groups), data, environment(formula)): object 'Chem97' not found Traceback: 1. densityplot(~gcsescore | factor(score), Chem97, groups = gender, . plot.points = FALSE, auto.key = TRUE) 2. densityplot.formula(~gcsescore | factor(score), Chem97, groups = gender, . plot.points = FALSE, auto.key = TRUE) 3. eval(substitute(groups), data, environment(formula))

INSTRUCTOR FEEDBACK see solutions for ideas.

Exercise 8

for(i in 1:10){ print("Hello world!") print(i*i) }
[1] "Hello world!" [1] 1 [1] "Hello world!" [1] 4 [1] "Hello world!" [1] 9 [1] "Hello world!" [1] 16 [1] "Hello world!" [1] 25 [1] "Hello world!" [1] 36 [1] "Hello world!" [1] 49 [1] "Hello world!" [1] 64 [1] "Hello world!" [1] 81 [1] "Hello world!" [1] 100
mydata<-rnorm(100,mean=0,sd=1) mydata2<-rnorm(100,mean=2,sd=1) par(mfrow=c(2, 2)) for(i in 1:2){ hist(mydata,col='red', prob=TRUE, ylim=c(0,0.45)) lines(density(mydata), pch=3, lty=i, col="blue") hist(mydata2,col='red',prob=TRUE) lines(density(mydata2), pch=3, lty=i, col="blue") #title(main=paste("lty = ",i), col.main="blue") }
Image in a Jupyter notebook
cleandata2<-rnorm(1000) A<-rnorm(1000) par(mfrow=c(2, 2)) for(i in 1:2){ hist(cleandata2,col='green', prob=TRUE, main="Clean smoke data without log transformation",cex.main=1.0, xlab="") lines(density(cleandata2), pch=3, lty=i, col="blue") hist(A,col='red',prob=TRUE, main="Clean smoke data with log transformation", cex.main=1.0, xlab="",ylim=c(0,0.45)) lines(density(A), pch=3, lty=i, col="blue") #title(main=paste("lty = ",i), col.main="blue") }
Image in a Jupyter notebook
  • Overall clarity (score = 0.25)

  • Correctness of the code (score = 0.25)

  • Exhaustive cover of required analysis (score= 0.25)

  • Interpretation of the results (score = 0.25)

  • Total Score = 1

Exercise 9

z <- 0 while(z < 5) { z <- z + 2 print(z) }
[1] 2 [1] 4 [1] 6

Reorganization of data

Ct_data <- read.csv("data_wk3/Ct_data.csv", header = TRUE) Ct_data
V1 V2 V3 1 40.000 18.010 23.684 2 10.689 14.455 21.211 3 26.276 13.791 21.652 4 14.877 20.407 26.446 5 23.972 22.347 22.231 6 13.871 19.857 23.965 7 32.987 18.636 20.707 8 24.659 40.000 32.147 9 18.903 15.492 23.371 10 40.000 40.000 18.621 11 23.597 18.811 21.903 12 22.536 21.954 29.702 13 23.239 27.539 27.370 14 11.345 18.919 28.319 15 28.168 22.384 40.000 16 22.507 14.979 40.000 17 18.622 13.154 25.924 18 27.852 40.000 20.260 19 21.913 19.899 19.860 20 21.913 26.150 26.397 21 25.456 19.578 25.362 22 25.412 25.792 32.671 23 40.000 24.537 22.742 24 17.877 15.436 11.149 25 21.938 17.142 25.800 26 40.000 16.928 19.172 27 28.105 15.298 19.676 28 22.079 19.844 25.000 29 23.322 24.323 23.793 30 40.000 18.642 24.078 ⋮ ⋮ ⋮ ⋮ 355 22.742 13.624 21.716 356 20.692 23.067 25.817 357 24.750 19.765 19.754 358 11.169 25.604 27.911 359 22.176 18.117 21.548 360 27.176 12.619 26.140 361 22.629 15.042 25.895 362 14.410 15.413 32.835 363 22.785 18.530 6.086 364 21.275 24.323 31.666 365 23.894 24.175 27.954 366 40.000 17.674 27.258 367 28.258 20.582 26.690 368 19.763 40.000 29.894 369 18.021 15.436 23.036 370 16.521 22.898 26.654 371 20.875 23.815 26.535 372 20.720 40.000 24.257 373 25.790 40.000 24.218 374 40.000 23.845 25.978 375 28.545 22.450 22.175 376 24.849 31.626 40.000 377 35.597 40.000 23.158 378 31.825 17.283 21.848 379 19.859 16.554 20.880 380 40.000 23.385 24.445 381 24.254 17.535 25.583 382 24.685 10.607 25.988 383 26.940 23.651 22.153 384 23.920 31.635 40.000
str(Ct_data)
'data.frame': 384 obs. of 3 variables: $ V1: num 40 10.7 26.3 14.9 24 ... $ V2: num 18 14.5 13.8 20.4 22.3 ... $ V3: num 23.7 21.2 21.7 26.4 22.2 ...
Ct_data <- read.csv("data_wk3/Ct_data.csv", header=TRUE) i<-1 j<-1 k<-1 Ct<-matrix(0,8,48) Ct_full<-matrix(0,24,48) cell_number<-dim(Ct_data)[1] step<-c(1,9,17) for (k in 1:1){ while (i<= (cell_number)) { Ct[,j]<-Ct_data[i:(i+7),k] i<-i+8 j<-j+1 } Ct_full[step[k]:(step[k]+7),]<-Ct i<-1 j<-1 } Ct Ct_full
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 40.000 18.903 18.622 21.938 14.487 18.780 35.385 17.439 18.148 28.215 [2,] 10.689 40.000 27.852 40.000 33.368 26.049 27.076 27.088 29.750 22.186 [3,] 26.276 23.597 21.913 28.105 20.244 19.911 40.000 20.699 20.676 22.411 [4,] 14.877 22.536 21.913 22.079 18.031 21.211 26.394 20.067 21.729 20.114 [5,] 23.972 23.239 25.456 23.322 24.934 28.429 20.383 23.619 23.197 23.594 [6,] 13.871 11.345 25.412 40.000 32.118 40.000 20.552 15.233 40.000 40.000 [7,] 32.987 28.168 40.000 40.000 30.817 18.850 32.173 40.000 34.128 40.000 [8,] 24.659 22.507 17.877 27.677 22.238 20.576 28.942 20.832 21.962 24.549 [,11] [,12] [,13] [,14] [,15] [,16] [,17] [,18] [,19] [,20] [1,] ⋯ 17.397 40.000 17.631 16.855 23.725 19.249 18.698 22.629 18.021 [2,] ⋯ 27.204 40.000 31.061 31.027 8.650 28.800 26.691 14.410 16.521 [3,] ⋯ 21.741 25.830 20.790 23.270 26.432 20.766 22.742 22.785 20.875 [4,] ⋯ 23.095 21.986 40.000 20.641 24.193 19.068 20.692 21.275 20.720 [5,] ⋯ 22.909 21.605 21.686 24.928 20.668 22.407 24.750 23.894 25.790 [6,] ⋯ 37.773 8.485 31.421 22.094 23.196 25.677 11.169 40.000 40.000 [7,] ⋯ 24.838 40.000 23.742 40.000 29.212 24.434 22.176 28.258 28.545 [8,] ⋯ 21.867 23.759 21.275 21.925 20.873 21.275 27.176 19.763 24.849 [,21] [1,] 35.597 [2,] 31.825 [3,] 19.859 [4,] 40.000 [5,] 24.254 [6,] 24.685 [7,] 26.940 [8,] 23.920
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 40.000 18.903 18.622 21.938 14.487 18.780 35.385 17.439 18.148 28.215 [2,] 10.689 40.000 27.852 40.000 33.368 26.049 27.076 27.088 29.750 22.186 [3,] 26.276 23.597 21.913 28.105 20.244 19.911 40.000 20.699 20.676 22.411 [4,] 14.877 22.536 21.913 22.079 18.031 21.211 26.394 20.067 21.729 20.114 [5,] 23.972 23.239 25.456 23.322 24.934 28.429 20.383 23.619 23.197 23.594 [6,] 13.871 11.345 25.412 40.000 32.118 40.000 20.552 15.233 40.000 40.000 [7,] 32.987 28.168 40.000 40.000 30.817 18.850 32.173 40.000 34.128 40.000 [8,] 24.659 22.507 17.877 27.677 22.238 20.576 28.942 20.832 21.962 24.549 [9,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [10,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [11,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [12,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [13,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [14,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [15,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [16,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [17,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [18,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [19,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [20,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [21,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [22,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [23,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [24,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [,11] [,12] [,13] [,14] [,15] [,16] [,17] [,18] [,19] [,20] [1,] ⋯ 17.397 40.000 17.631 16.855 23.725 19.249 18.698 22.629 18.021 [2,] ⋯ 27.204 40.000 31.061 31.027 8.650 28.800 26.691 14.410 16.521 [3,] ⋯ 21.741 25.830 20.790 23.270 26.432 20.766 22.742 22.785 20.875 [4,] ⋯ 23.095 21.986 40.000 20.641 24.193 19.068 20.692 21.275 20.720 [5,] ⋯ 22.909 21.605 21.686 24.928 20.668 22.407 24.750 23.894 25.790 [6,] ⋯ 37.773 8.485 31.421 22.094 23.196 25.677 11.169 40.000 40.000 [7,] ⋯ 24.838 40.000 23.742 40.000 29.212 24.434 22.176 28.258 28.545 [8,] ⋯ 21.867 23.759 21.275 21.925 20.873 21.275 27.176 19.763 24.849 [9,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [10,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [11,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [12,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [13,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [14,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [15,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [16,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [17,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [18,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [19,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [20,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [21,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [22,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [23,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [24,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [,21] [1,] 35.597 [2,] 31.825 [3,] 19.859 [4,] 40.000 [5,] 24.254 [6,] 24.685 [7,] 26.940 [8,] 23.920 [9,] 0.000 [10,] 0.000 [11,] 0.000 [12,] 0.000 [13,] 0.000 [14,] 0.000 [15,] 0.000 [16,] 0.000 [17,] 0.000 [18,] 0.000 [19,] 0.000 [20,] 0.000 [21,] 0.000 [22,] 0.000 [23,] 0.000 [24,] 0.000
str(Ct)
num [1:8, 1:48] 40 10.7 26.3 14.9 24 ...
str(Ct_full)
num [1:24, 1:48] 40 10.7 26.3 14.9 24 ...
targetNames<-read.csv("data_wk3/targetNames.csv", header=FALSE) full_target<-c(targetNames[1:8,1],targetNames[1:8,2],targetNames[1:8,3]) rownames(Ct_full)<-full_target targetNames
V1 V2 V3 1 RPLPO NANOG MEIS1 2 RNA SPIKE OCT3-4 SOX2 3 B-ACTIN PAX6 ATOH1 4 PAX2 BRN3A BRN3C 5 PAX8 NESTIN MYOSIN7A 6 FOXG1 SIX1 SOX9 7 DLX5 GATA3 SYP 8 GFP RNA SPIKE H10_1 RNA SPIKE H10 9 RPLPO NANOG MEIS1 10 RNA SPIKE OCT3-4 SOX2 11 B-ACTIN PAX6 ATOH1 12 PAX2 BRN3A BRN3C 13 PAX8 NESTIN MYOSIN7A 14 FOXG1 SIX1 SOX9 15 DLX5 GATA3 SYP 16 GFP RNA SPIKE H10_1 RNA SPIKE H10 17 RPLPO NANOG MEIS1 18 RNA SPIKE OCT3-4 SOX2 19 B-ACTIN PAX6 ATOH1 20 PAX2 BRN3A BRN3C 21 PAX8 NESTIN MYOSIN7A 22 FOXG1 SIX1 SOX9 23 DLX5 GATA3 SYP 24 GFP RNA SPIKE H10_1 RNA SPIKE H10 25 RPLPO NANOG MEIS1 26 RNA SPIKE OCT3-4 SOX2 27 B-ACTIN PAX6 ATOH1 28 PAX2 BRN3A BRN3C 29 PAX8 NESTIN MYOSIN7A 30 FOXG1 SIX1 SOX9 ⋮ ⋮ ⋮ ⋮ 355 B-ACTIN PAX6 ATOH1 356 PAX2 BRN3A BRN3C 357 PAX8 NESTIN MYOSIN7A 358 FOXG1 SIX1 SOX9 359 DLX5 GATA3 SYP 360 GFP RNA SPIKE H10_1 RNA SPIKE H10 361 RPLPO NANOG MEIS1 362 RNA SPIKE OCT3-4 SOX2 363 B-ACTIN PAX6 ATOH1 364 PAX2 BRN3A BRN3C 365 PAX8 NESTIN MYOSIN7A 366 FOXG1 SIX1 SOX9 367 DLX5 GATA3 SYP 368 GFP RNA SPIKE H10_1 RNA SPIKE H10 369 RPLPO NANOG MEIS1 370 RNA SPIKE OCT3-4 SOX2 371 B-ACTIN PAX6 ATOH1 372 PAX2 BRN3A BRN3C 373 PAX8 NESTIN MYOSIN7A 374 FOXG1 SIX1 SOX9 375 DLX5 GATA3 SYP 376 GFP RNA SPIKE H10_1 RNA SPIKE H10 377 RPLPO NANOG MEIS1 378 RNA SPIKE OCT3-4 SOX2 379 B-ACTIN PAX6 ATOH1 380 PAX2 BRN3A BRN3C 381 PAX8 NESTIN MYOSIN7A 382 FOXG1 SIX1 SOX9 383 DLX5 GATA3 SYP 384 GFP RNA SPIKE H10_1 RNA SPIKE H10
str(targetNames)
'data.frame': 384 obs. of 48 variables: $ V1 : Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V2 : Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V3 : Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V4 : Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V5 : Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V6 : Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V7 : Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V8 : Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V9 : Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V10: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V11: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V12: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V13: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V14: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V15: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V16: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V17: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V18: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V19: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V20: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V21: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V22: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V23: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V24: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V25: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V26: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V27: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V28: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V29: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V30: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V31: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V32: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V33: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V34: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V35: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V36: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V37: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V38: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V39: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V40: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V41: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V42: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V43: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V44: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V45: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V46: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V47: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ... $ V48: Factor w/ 8 levels "B-ACTIN","DLX5",..: 8 7 1 5 6 3 2 4 8 7 ...
Ct_data <- read.csv("data_wk3/Ct_data.csv", header=TRUE) i<-1 j<-1 k<-1 Ct<-matrix(0,8,48) Ct_full<-matrix(0,24,48) cell_number<-dim(Ct_data)[1] step<-c(1,9,17) for (k in 1:1){ while (i<= (cell_number)) { Ct[,j]<-Ct_data[i:(i+7),k] i<-i+8 j<-j+1 } Ct_full[step[k]:(step[k]+7),]<-Ct i<-1 j<-1 } Ct Ct_full
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 40.000 18.903 18.622 21.938 14.487 18.780 35.385 17.439 18.148 28.215 [2,] 10.689 40.000 27.852 40.000 33.368 26.049 27.076 27.088 29.750 22.186 [3,] 26.276 23.597 21.913 28.105 20.244 19.911 40.000 20.699 20.676 22.411 [4,] 14.877 22.536 21.913 22.079 18.031 21.211 26.394 20.067 21.729 20.114 [5,] 23.972 23.239 25.456 23.322 24.934 28.429 20.383 23.619 23.197 23.594 [6,] 13.871 11.345 25.412 40.000 32.118 40.000 20.552 15.233 40.000 40.000 [7,] 32.987 28.168 40.000 40.000 30.817 18.850 32.173 40.000 34.128 40.000 [8,] 24.659 22.507 17.877 27.677 22.238 20.576 28.942 20.832 21.962 24.549 [,11] [,12] [,13] [,14] [,15] [,16] [,17] [,18] [,19] [,20] [1,] ⋯ 17.397 40.000 17.631 16.855 23.725 19.249 18.698 22.629 18.021 [2,] ⋯ 27.204 40.000 31.061 31.027 8.650 28.800 26.691 14.410 16.521 [3,] ⋯ 21.741 25.830 20.790 23.270 26.432 20.766 22.742 22.785 20.875 [4,] ⋯ 23.095 21.986 40.000 20.641 24.193 19.068 20.692 21.275 20.720 [5,] ⋯ 22.909 21.605 21.686 24.928 20.668 22.407 24.750 23.894 25.790 [6,] ⋯ 37.773 8.485 31.421 22.094 23.196 25.677 11.169 40.000 40.000 [7,] ⋯ 24.838 40.000 23.742 40.000 29.212 24.434 22.176 28.258 28.545 [8,] ⋯ 21.867 23.759 21.275 21.925 20.873 21.275 27.176 19.763 24.849 [,21] [1,] 35.597 [2,] 31.825 [3,] 19.859 [4,] 40.000 [5,] 24.254 [6,] 24.685 [7,] 26.940 [8,] 23.920
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 40.000 18.903 18.622 21.938 14.487 18.780 35.385 17.439 18.148 28.215 [2,] 10.689 40.000 27.852 40.000 33.368 26.049 27.076 27.088 29.750 22.186 [3,] 26.276 23.597 21.913 28.105 20.244 19.911 40.000 20.699 20.676 22.411 [4,] 14.877 22.536 21.913 22.079 18.031 21.211 26.394 20.067 21.729 20.114 [5,] 23.972 23.239 25.456 23.322 24.934 28.429 20.383 23.619 23.197 23.594 [6,] 13.871 11.345 25.412 40.000 32.118 40.000 20.552 15.233 40.000 40.000 [7,] 32.987 28.168 40.000 40.000 30.817 18.850 32.173 40.000 34.128 40.000 [8,] 24.659 22.507 17.877 27.677 22.238 20.576 28.942 20.832 21.962 24.549 [9,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [10,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [11,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [12,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [13,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [14,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [15,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [16,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [17,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [18,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [19,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [20,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [21,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [22,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [23,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [24,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [,11] [,12] [,13] [,14] [,15] [,16] [,17] [,18] [,19] [,20] [1,] ⋯ 17.397 40.000 17.631 16.855 23.725 19.249 18.698 22.629 18.021 [2,] ⋯ 27.204 40.000 31.061 31.027 8.650 28.800 26.691 14.410 16.521 [3,] ⋯ 21.741 25.830 20.790 23.270 26.432 20.766 22.742 22.785 20.875 [4,] ⋯ 23.095 21.986 40.000 20.641 24.193 19.068 20.692 21.275 20.720 [5,] ⋯ 22.909 21.605 21.686 24.928 20.668 22.407 24.750 23.894 25.790 [6,] ⋯ 37.773 8.485 31.421 22.094 23.196 25.677 11.169 40.000 40.000 [7,] ⋯ 24.838 40.000 23.742 40.000 29.212 24.434 22.176 28.258 28.545 [8,] ⋯ 21.867 23.759 21.275 21.925 20.873 21.275 27.176 19.763 24.849 [9,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [10,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [11,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [12,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [13,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [14,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [15,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [16,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [17,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [18,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [19,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [20,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [21,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [22,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [23,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [24,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [,21] [1,] 35.597 [2,] 31.825 [3,] 19.859 [4,] 40.000 [5,] 24.254 [6,] 24.685 [7,] 26.940 [8,] 23.920 [9,] 0.000 [10,] 0.000 [11,] 0.000 [12,] 0.000 [13,] 0.000 [14,] 0.000 [15,] 0.000 [16,] 0.000 [17,] 0.000 [18,] 0.000 [19,] 0.000 [20,] 0.000 [21,] 0.000 [22,] 0.000 [23,] 0.000 [24,] 0.000
targetNames<-read.csv("data_wk3/targetNames.csv", header=FALSE) i<-1 j<-1 k<-1 target<-matrix(0,8,48) target_full<-matrix(0,24,48) cell_number<-dim(targetNames)[1] step<-c(1,9,17) for (k in 1:1){ while (i<= (cell_number)) { target[,j]<-targetNames[i:(i+7),k] i<-i+8 j<-j+1 } target_full[step[k]:(step[k]+7),]<-target i<-1 j<-1 } target target_full
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [1,] 8 8 8 8 8 8 8 8 8 8 ⋯ 8 8 8 [2,] 7 7 7 7 7 7 7 7 7 7 ⋯ 7 7 7 [3,] 1 1 1 1 1 1 1 1 1 1 ⋯ 1 1 1 [4,] 5 5 5 5 5 5 5 5 5 5 ⋯ 5 5 5 [5,] 6 6 6 6 6 6 6 6 6 6 ⋯ 6 6 6 [6,] 3 3 3 3 3 3 3 3 3 3 ⋯ 3 3 3 [7,] 2 2 2 2 2 2 2 2 2 2 ⋯ 2 2 2 [8,] 4 4 4 4 4 4 4 4 4 4 ⋯ 4 4 4 [,15] [,16] [,17] [,18] [,19] [,20] [,21] [1,] 8 8 8 8 8 8 8 [2,] 7 7 7 7 7 7 7 [3,] 1 1 1 1 1 1 1 [4,] 5 5 5 5 5 5 5 [5,] 6 6 6 6 6 6 6 [6,] 3 3 3 3 3 3 3 [7,] 2 2 2 2 2 2 2 [8,] 4 4 4 4 4 4 4
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [1,] 8 8 8 8 8 8 8 8 8 8 ⋯ 8 8 [2,] 7 7 7 7 7 7 7 7 7 7 ⋯ 7 7 [3,] 1 1 1 1 1 1 1 1 1 1 ⋯ 1 1 [4,] 5 5 5 5 5 5 5 5 5 5 ⋯ 5 5 [5,] 6 6 6 6 6 6 6 6 6 6 ⋯ 6 6 [6,] 3 3 3 3 3 3 3 3 3 3 ⋯ 3 3 [7,] 2 2 2 2 2 2 2 2 2 2 ⋯ 2 2 [8,] 4 4 4 4 4 4 4 4 4 4 ⋯ 4 4 [9,] 0 0 0 0 0 0 0 0 0 0 ⋯ 0 0 [10,] 0 0 0 0 0 0 0 0 0 0 ⋯ 0 0 [11,] 0 0 0 0 0 0 0 0 0 0 ⋯ 0 0 [12,] 0 0 0 0 0 0 0 0 0 0 ⋯ 0 0 [13,] 0 0 0 0 0 0 0 0 0 0 ⋯ 0 0 [14,] 0 0 0 0 0 0 0 0 0 0 ⋯ 0 0 [15,] 0 0 0 0 0 0 0 0 0 0 ⋯ 0 0 [16,] 0 0 0 0 0 0 0 0 0 0 ⋯ 0 0 [17,] 0 0 0 0 0 0 0 0 0 0 ⋯ 0 0 [18,] 0 0 0 0 0 0 0 0 0 0 ⋯ 0 0 [19,] 0 0 0 0 0 0 0 0 0 0 ⋯ 0 0 [20,] 0 0 0 0 0 0 0 0 0 0 ⋯ 0 0 [21,] 0 0 0 0 0 0 0 0 0 0 ⋯ 0 0 [22,] 0 0 0 0 0 0 0 0 0 0 ⋯ 0 0 [23,] 0 0 0 0 0 0 0 0 0 0 ⋯ 0 0 [24,] 0 0 0 0 0 0 0 0 0 0 ⋯ 0 0 [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [1,] 8 8 8 8 8 8 8 8 [2,] 7 7 7 7 7 7 7 7 [3,] 1 1 1 1 1 1 1 1 [4,] 5 5 5 5 5 5 5 5 [5,] 6 6 6 6 6 6 6 6 [6,] 3 3 3 3 3 3 3 3 [7,] 2 2 2 2 2 2 2 2 [8,] 4 4 4 4 4 4 4 4 [9,] 0 0 0 0 0 0 0 0 [10,] 0 0 0 0 0 0 0 0 [11,] 0 0 0 0 0 0 0 0 [12,] 0 0 0 0 0 0 0 0 [13,] 0 0 0 0 0 0 0 0 [14,] 0 0 0 0 0 0 0 0 [15,] 0 0 0 0 0 0 0 0 [16,] 0 0 0 0 0 0 0 0 [17,] 0 0 0 0 0 0 0 0 [18,] 0 0 0 0 0 0 0 0 [19,] 0 0 0 0 0 0 0 0 [20,] 0 0 0 0 0 0 0 0 [21,] 0 0 0 0 0 0 0 0 [22,] 0 0 0 0 0 0 0 0 [23,] 0 0 0 0 0 0 0 0 [24,] 0 0 0 0 0 0 0 0
str(target)
num [1:8, 1:48] 8 7 1 5 6 3 2 4 8 7 ...
deltaCt<-sweep(Ct_full,MARGIN=2,Ct_full[1,],FUN="-") deltaCt
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [1,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [2,] -29.311 21.097 9.230 18.062 18.881 7.269 -8.309 9.649 11.602 [3,] -13.724 4.694 3.291 6.167 5.757 1.131 4.615 3.260 2.528 [4,] -25.123 3.633 3.291 0.141 3.544 2.431 -8.991 2.628 3.581 [5,] -16.028 4.336 6.834 1.384 10.447 9.649 -15.002 6.180 5.049 [6,] -26.129 -7.558 6.790 18.062 17.631 21.220 -14.833 -2.206 21.852 [7,] -7.013 9.265 21.378 18.062 16.330 0.070 -3.212 22.561 15.980 [8,] -15.341 3.604 -0.745 5.739 7.751 1.796 -6.443 3.393 3.814 [9,] -40.000 -18.903 -18.622 -21.938 -14.487 -18.780 -35.385 -17.439 -18.148 [10,] -40.000 -18.903 -18.622 -21.938 -14.487 -18.780 -35.385 -17.439 -18.148 [11,] -40.000 -18.903 -18.622 -21.938 -14.487 -18.780 -35.385 -17.439 -18.148 [12,] -40.000 -18.903 -18.622 -21.938 -14.487 -18.780 -35.385 -17.439 -18.148 [13,] -40.000 -18.903 -18.622 -21.938 -14.487 -18.780 -35.385 -17.439 -18.148 [14,] -40.000 -18.903 -18.622 -21.938 -14.487 -18.780 -35.385 -17.439 -18.148 [15,] -40.000 -18.903 -18.622 -21.938 -14.487 -18.780 -35.385 -17.439 -18.148 [16,] -40.000 -18.903 -18.622 -21.938 -14.487 -18.780 -35.385 -17.439 -18.148 [17,] -40.000 -18.903 -18.622 -21.938 -14.487 -18.780 -35.385 -17.439 -18.148 [18,] -40.000 -18.903 -18.622 -21.938 -14.487 -18.780 -35.385 -17.439 -18.148 [19,] -40.000 -18.903 -18.622 -21.938 -14.487 -18.780 -35.385 -17.439 -18.148 [20,] -40.000 -18.903 -18.622 -21.938 -14.487 -18.780 -35.385 -17.439 -18.148 [21,] -40.000 -18.903 -18.622 -21.938 -14.487 -18.780 -35.385 -17.439 -18.148 [22,] -40.000 -18.903 -18.622 -21.938 -14.487 -18.780 -35.385 -17.439 -18.148 [23,] -40.000 -18.903 -18.622 -21.938 -14.487 -18.780 -35.385 -17.439 -18.148 [24,] -40.000 -18.903 -18.622 -21.938 -14.487 -18.780 -35.385 -17.439 -18.148 [,10] [,11] [,12] [,13] [,14] [,15] [,16] [,17] [,18] [1,] 0.000 ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [2,] -6.029 ⋯ 9.807 0.000 13.430 14.172 -15.075 9.551 7.993 [3,] -5.804 ⋯ 4.344 -14.170 3.159 6.415 2.707 1.517 4.044 [4,] -8.101 ⋯ 5.698 -18.014 22.369 3.786 0.468 -0.181 1.994 [5,] -4.621 ⋯ 5.512 -18.395 4.055 8.073 -3.057 3.158 6.052 [6,] 11.785 ⋯ 20.376 -31.515 13.790 5.239 -0.529 6.428 -7.529 [7,] 11.785 ⋯ 7.441 0.000 6.111 23.145 5.487 5.185 3.478 [8,] -3.666 ⋯ 4.470 -16.241 3.644 5.070 -2.852 2.026 8.478 [9,] -28.215 ⋯ -17.397 -40.000 -17.631 -16.855 -23.725 -19.249 -18.698 [10,] -28.215 ⋯ -17.397 -40.000 -17.631 -16.855 -23.725 -19.249 -18.698 [11,] -28.215 ⋯ -17.397 -40.000 -17.631 -16.855 -23.725 -19.249 -18.698 [12,] -28.215 ⋯ -17.397 -40.000 -17.631 -16.855 -23.725 -19.249 -18.698 [13,] -28.215 ⋯ -17.397 -40.000 -17.631 -16.855 -23.725 -19.249 -18.698 [14,] -28.215 ⋯ -17.397 -40.000 -17.631 -16.855 -23.725 -19.249 -18.698 [15,] -28.215 ⋯ -17.397 -40.000 -17.631 -16.855 -23.725 -19.249 -18.698 [16,] -28.215 ⋯ -17.397 -40.000 -17.631 -16.855 -23.725 -19.249 -18.698 [17,] -28.215 ⋯ -17.397 -40.000 -17.631 -16.855 -23.725 -19.249 -18.698 [18,] -28.215 ⋯ -17.397 -40.000 -17.631 -16.855 -23.725 -19.249 -18.698 [19,] -28.215 ⋯ -17.397 -40.000 -17.631 -16.855 -23.725 -19.249 -18.698 [20,] -28.215 ⋯ -17.397 -40.000 -17.631 -16.855 -23.725 -19.249 -18.698 [21,] -28.215 ⋯ -17.397 -40.000 -17.631 -16.855 -23.725 -19.249 -18.698 [22,] -28.215 ⋯ -17.397 -40.000 -17.631 -16.855 -23.725 -19.249 -18.698 [23,] -28.215 ⋯ -17.397 -40.000 -17.631 -16.855 -23.725 -19.249 -18.698 [24,] -28.215 ⋯ -17.397 -40.000 -17.631 -16.855 -23.725 -19.249 -18.698 [,19] [,20] [,21] [1,] 0.000 0.000 0.000 [2,] -8.219 -1.500 -3.772 [3,] 0.156 2.854 -15.738 [4,] -1.354 2.699 4.403 [5,] 1.265 7.769 -11.343 [6,] 17.371 21.979 -10.912 [7,] 5.629 10.524 -8.657 [8,] -2.866 6.828 -11.677 [9,] -22.629 -18.021 -35.597 [10,] -22.629 -18.021 -35.597 [11,] -22.629 -18.021 -35.597 [12,] -22.629 -18.021 -35.597 [13,] -22.629 -18.021 -35.597 [14,] -22.629 -18.021 -35.597 [15,] -22.629 -18.021 -35.597 [16,] -22.629 -18.021 -35.597 [17,] -22.629 -18.021 -35.597 [18,] -22.629 -18.021 -35.597 [19,] -22.629 -18.021 -35.597 [20,] -22.629 -18.021 -35.597 [21,] -22.629 -18.021 -35.597 [22,] -22.629 -18.021 -35.597 [23,] -22.629 -18.021 -35.597 [24,] -22.629 -18.021 -35.597
str(deltaCt)
num [1:24, 1:48] 0 -29.3 -13.7 -25.1 -16 ...
geneexp <- function(a) { ux <- a*(2*exp(-deltaCt)) return(ux) } geneexp(Ct_full)
[,1] [,2] [,3] [,4] [,5] [1,] 8.000000e+01 3.780600e+01 3.724400e+01 4.387600e+01 2.897400e+01 [2,] 1.147024e+14 5.505279e-08 5.461957e-03 1.145152e-06 4.211590e-07 [3,] 4.795642e+07 4.318257e-01 1.631055e+00 1.179016e-01 1.279655e-01 [4,] 2.422845e+12 1.191557e+00 1.631055e+00 3.835075e+01 1.042102e+00 [5,] 4.381333e+08 6.083403e-01 5.480897e-02 1.168779e+01 1.447930e-03 [6,] 6.177579e+12 4.347426e+04 5.717541e-02 1.145152e-06 1.414922e-06 [7,] 7.329596e+04 5.333934e-03 4.156641e-08 1.145152e-06 4.986450e-06 [8,] 2.267342e+08 1.225040e+00 7.531371e+01 1.781283e-01 1.913856e-02 [9,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [10,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [11,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [12,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [13,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [14,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [15,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [16,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [17,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [18,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [19,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [20,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [21,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [22,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [23,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [24,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [,6] [,7] [,8] [,9] [,10] [,11] [1,] 3.756000e+01 7.077000e+01 3.487800e+01 3.629600e+01 5.643000e+01 ⋯ [2,] 3.630233e-02 2.198707e+05 3.493812e-03 5.442925e-04 1.842767e+04 ⋯ [3,] 1.285097e+01 7.921747e-01 1.589203e+00 3.300655e+00 1.486402e+04 ⋯ [4,] 3.730966e+00 4.239132e+05 2.898588e+00 1.210211e+00 1.326625e+05 ⋯ [5,] 3.666774e-03 1.335316e+08 9.780287e-02 2.976521e-01 4.794092e+03 ⋯ [6,] 4.868118e-08 1.137036e+08 2.766108e+02 2.587539e-08 6.094380e-04 ⋯ [7,] 3.515125e+01 1.597627e+03 1.273422e-08 7.836371e-06 6.094380e-04 ⋯ [8,] 6.829644e+00 3.636787e+04 1.400231e+00 9.689530e-01 1.919497e+03 ⋯ [9,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 ⋯ [10,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 ⋯ [11,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 ⋯ [12,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 ⋯ [13,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 ⋯ [14,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 ⋯ [15,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 ⋯ [16,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 ⋯ [17,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 ⋯ [18,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 ⋯ [19,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 ⋯ [20,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 ⋯ [21,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 ⋯ [22,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 ⋯ [23,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 ⋯ [24,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 ⋯ [,12] [,13] [,14] [,15] [,16] [1,] 3.479400e+01 8.000000e+01 3.526200e+01 3.371000e+01 4.745000e+01 [2,] 2.995965e-03 8.000000e+01 9.134200e-05 4.344586e-05 6.095866e+07 [3,] 5.645914e-01 7.363889e+07 1.765827e+00 7.617760e-02 3.527970e+00 [4,] 1.548596e-01 2.927905e+09 1.542967e-08 9.365303e-01 3.030190e+01 [5,] 1.850141e-01 4.211446e+09 7.518744e-01 1.554741e-02 8.789551e+02 [6,] 1.069122e-07 8.250351e+14 6.446576e-05 2.344421e-01 7.873809e+01 [7,] 2.914482e-02 8.000000e+01 1.053352e-01 7.101404e-09 2.418897e-01 [8,] 5.006369e-01 5.373223e+08 1.112578e+00 2.754841e-01 7.231406e+02 [9,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [10,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [11,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [12,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [13,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [14,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [15,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [16,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [17,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [18,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [19,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [20,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [21,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [22,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [23,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [24,] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [,17] [,18] [,19] [,20] [,21] [1,] 38.498000000 3.739600e+01 4.525800e+01 3.604200e+01 7.119400e+01 [2,] 0.004097094 1.803346e-02 1.069450e+05 1.480840e+02 2.766669e+03 [3,] 9.110833632 7.972082e-01 3.898783e+01 2.405360e+00 2.715901e+08 [4,] 45.702761278 5.634421e+00 1.647913e+02 2.787783e+00 9.792450e-01 [5,] 1.905073500 1.164810e-01 1.348765e+01 2.179955e-02 4.092754e+06 [6,] 0.082971577 4.157645e+04 2.285391e-06 2.278933e-08 2.706977e+06 [7,] 0.273657703 1.369106e+00 2.030148e-01 1.534776e-03 3.098239e+05 [8,] 5.610724497 1.130490e-02 6.943379e+02 5.382403e-02 5.636997e+06 [9,] 0.000000000 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [10,] 0.000000000 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [11,] 0.000000000 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [12,] 0.000000000 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [13,] 0.000000000 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [14,] 0.000000000 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [15,] 0.000000000 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [16,] 0.000000000 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [17,] 0.000000000 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [18,] 0.000000000 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [19,] 0.000000000 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [20,] 0.000000000 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [21,] 0.000000000 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [22,] 0.000000000 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [23,] 0.000000000 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 [24,] 0.000000000 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00
boxplot(geneexp~Ct_full, col="light grey", xlab="Genes",ylab="Gene expression", main="Bioconductor Experiment")
Error in model.frame.default(formula = geneexp ~ Ct_full): object is not a matrix Traceback: 1. boxplot(geneexp ~ Ct_full, col = "light grey", xlab = "Genes", . ylab = "Gene expression", main = "Bioconductor Experiment") 2. boxplot.formula(geneexp ~ Ct_full, col = "light grey", xlab = "Genes", . ylab = "Gene expression", main = "Bioconductor Experiment") 3. eval(m, parent.frame()) 4. eval(expr, envir, enclos) 5. stats::model.frame(formula = geneexp ~ Ct_full) 6. model.frame.default(formula = geneexp ~ Ct_full)
  • Overall clarity (score = 0.25)

  • Correctness of the code (score = 0.25)

  • Exhaustive cover of required analysis (score= 0.25)

  • Interpretation of the results (score = 0.25)

  • Total Score = 1

** INSTRUCTOR FEEDBACK** make sure you always resolve the errors. Don't leave them. Score:0.75

Exercise 11

med_att <- apply(deltaCt, 2, median) scaledData<-sweep(data.matrix(deltaCt), 2, med_att) med_att scaledData
[1] -40.000 -18.903 -18.622 -21.938 -14.487 -18.780 -35.385 -17.439 -18.148 [10] -28.215 -17.225 -18.242 -21.942 -18.224 -40.000 -18.784 -17.253 -17.814 [19] -19.107 -19.131 -21.285 -18.126 -18.138 -19.513 -16.911 -15.311 -18.811 [28] -17.846 -16.762 -19.202 -18.768 -14.374 -17.827 -19.473 -17.257 -17.024 [37] -20.528 -15.126 -17.397 -40.000 -17.631 -16.855 -23.725 -19.249 -18.698 [46] -22.629 -18.021 -35.597
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 40.000 18.903 18.622 21.938 14.487 18.780 35.385 17.439 18.148 28.215 [2,] 10.689 40.000 27.852 40.000 33.368 26.049 27.076 27.088 29.750 22.186 [3,] 26.276 23.597 21.913 28.105 20.244 19.911 40.000 20.699 20.676 22.411 [4,] 14.877 22.536 21.913 22.079 18.031 21.211 26.394 20.067 21.729 20.114 [5,] 23.972 23.239 25.456 23.322 24.934 28.429 20.383 23.619 23.197 23.594 [6,] 13.871 11.345 25.412 40.000 32.118 40.000 20.552 15.233 40.000 40.000 [7,] 32.987 28.168 40.000 40.000 30.817 18.850 32.173 40.000 34.128 40.000 [8,] 24.659 22.507 17.877 27.677 22.238 20.576 28.942 20.832 21.962 24.549 [9,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [10,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [11,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [12,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [13,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [14,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [15,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [16,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [17,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [18,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [19,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [20,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [21,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [22,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [23,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [24,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [,11] [,12] [,13] [,14] [,15] [,16] [,17] [,18] [,19] [,20] [1,] ⋯ 17.397 40.000 17.631 16.855 23.725 19.249 18.698 22.629 18.021 [2,] ⋯ 27.204 40.000 31.061 31.027 8.650 28.800 26.691 14.410 16.521 [3,] ⋯ 21.741 25.830 20.790 23.270 26.432 20.766 22.742 22.785 20.875 [4,] ⋯ 23.095 21.986 40.000 20.641 24.193 19.068 20.692 21.275 20.720 [5,] ⋯ 22.909 21.605 21.686 24.928 20.668 22.407 24.750 23.894 25.790 [6,] ⋯ 37.773 8.485 31.421 22.094 23.196 25.677 11.169 40.000 40.000 [7,] ⋯ 24.838 40.000 23.742 40.000 29.212 24.434 22.176 28.258 28.545 [8,] ⋯ 21.867 23.759 21.275 21.925 20.873 21.275 27.176 19.763 24.849 [9,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [10,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [11,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [12,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [13,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [14,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [15,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [16,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [17,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [18,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [19,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [20,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [21,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [22,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [23,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [24,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [,21] [1,] 35.597 [2,] 31.825 [3,] 19.859 [4,] 40.000 [5,] 24.254 [6,] 24.685 [7,] 26.940 [8,] 23.920 [9,] 0.000 [10,] 0.000 [11,] 0.000 [12,] 0.000 [13,] 0.000 [14,] 0.000 [15,] 0.000 [16,] 0.000 [17,] 0.000 [18,] 0.000 [19,] 0.000 [20,] 0.000 [21,] 0.000 [22,] 0.000 [23,] 0.000 [24,] 0.000
?med_att
med_att <- apply(Ct_full,2, median) scaledData<-sweep(data.matrix(Ct_full),2,med_att) med_att scaledData
[1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [39] 0 0 0 0 0 0 0 0 0 0
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 40.000 18.903 18.622 21.938 14.487 18.780 35.385 17.439 18.148 28.215 [2,] 10.689 40.000 27.852 40.000 33.368 26.049 27.076 27.088 29.750 22.186 [3,] 26.276 23.597 21.913 28.105 20.244 19.911 40.000 20.699 20.676 22.411 [4,] 14.877 22.536 21.913 22.079 18.031 21.211 26.394 20.067 21.729 20.114 [5,] 23.972 23.239 25.456 23.322 24.934 28.429 20.383 23.619 23.197 23.594 [6,] 13.871 11.345 25.412 40.000 32.118 40.000 20.552 15.233 40.000 40.000 [7,] 32.987 28.168 40.000 40.000 30.817 18.850 32.173 40.000 34.128 40.000 [8,] 24.659 22.507 17.877 27.677 22.238 20.576 28.942 20.832 21.962 24.549 [9,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [10,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [11,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [12,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [13,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [14,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [15,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [16,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [17,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [18,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [19,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [20,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [21,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [22,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [23,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [24,] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [,11] [,12] [,13] [,14] [,15] [,16] [,17] [,18] [,19] [,20] [1,] ⋯ 17.397 40.000 17.631 16.855 23.725 19.249 18.698 22.629 18.021 [2,] ⋯ 27.204 40.000 31.061 31.027 8.650 28.800 26.691 14.410 16.521 [3,] ⋯ 21.741 25.830 20.790 23.270 26.432 20.766 22.742 22.785 20.875 [4,] ⋯ 23.095 21.986 40.000 20.641 24.193 19.068 20.692 21.275 20.720 [5,] ⋯ 22.909 21.605 21.686 24.928 20.668 22.407 24.750 23.894 25.790 [6,] ⋯ 37.773 8.485 31.421 22.094 23.196 25.677 11.169 40.000 40.000 [7,] ⋯ 24.838 40.000 23.742 40.000 29.212 24.434 22.176 28.258 28.545 [8,] ⋯ 21.867 23.759 21.275 21.925 20.873 21.275 27.176 19.763 24.849 [9,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [10,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [11,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [12,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [13,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [14,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [15,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [16,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [17,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [18,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [19,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [20,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [21,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [22,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [23,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [24,] ⋯ 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [,21] [1,] 35.597 [2,] 31.825 [3,] 19.859 [4,] 40.000 [5,] 24.254 [6,] 24.685 [7,] 26.940 [8,] 23.920 [9,] 0.000 [10,] 0.000 [11,] 0.000 [12,] 0.000 [13,] 0.000 [14,] 0.000 [15,] 0.000 [16,] 0.000 [17,] 0.000 [18,] 0.000 [19,] 0.000 [20,] 0.000 [21,] 0.000 [22,] 0.000 [23,] 0.000 [24,] 0.000
?index
quantile_normalisation <- function(df){ df_rank <- apply(df,2,rank,ties.method="average") df_sorted <- data.frame(apply(df, 2, sort)) df_mean <- apply(df_sorted, 1, mean) index_to_mean <- function(my_index, my_mean){ return(my_mean[my_index]) } df_final <- apply(df_rank, 2, index_to_mean, my_mean=df_mean) rownames(df_final) <- rownames(df) return(df_final) } quantile_normalisation(deltaCt)
[,1] [,2] [,3] [,4] [,5] [,6] [1,] 16.9899167 -0.7427083 -0.7427083 -4.3804583 -4.3804583 -4.3804583 [2,] -4.3804583 16.9899167 12.0150625 12.0150625 16.9899167 7.5447500 [3,] 7.5447500 7.5447500 0.8358958 4.2420000 0.8358958 0.8358958 [4,] 0.8358958 2.4279583 0.8358958 -0.7427083 -0.7427083 4.2420000 [5,] 2.4279583 4.2420000 7.5447500 0.8358958 4.2420000 12.0150625 [6,] -0.7427083 -4.3804583 4.2420000 12.0150625 12.0150625 16.9899167 [7,] 12.0150625 12.0150625 16.9899167 12.0150625 7.5447500 -0.7427083 [8,] 4.2420000 0.8358958 -4.3804583 2.4279583 2.4279583 2.4279583 [9,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 [10,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 [11,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 [12,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 [13,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 [14,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 [15,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 [16,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 [17,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 [18,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 [19,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 [20,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 [21,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 [22,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 [23,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 [24,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 [,7] [,8] [,9] [,10] [,11] [,12] [1,] 12.0150625 -0.7427083 -4.3804583 7.5447500 ⋯ -4.3804583 [2,] 2.4279583 12.0150625 7.5447500 -0.7427083 ⋯ 12.0150625 [3,] 16.9899167 2.4279583 -0.7427083 0.8358958 ⋯ -0.7427083 [4,] 0.8358958 0.8358958 0.8358958 -4.3804583 ⋯ 4.2420000 [5,] -4.3804583 7.5447500 4.2420000 2.4279583 ⋯ 2.4279583 [6,] -0.7427083 -4.3804583 16.9899167 12.0150625 ⋯ 16.9899167 [7,] 7.5447500 16.9899167 12.0150625 12.0150625 ⋯ 7.5447500 [8,] 4.2420000 4.2420000 2.4279583 4.2420000 ⋯ 0.8358958 [9,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 ⋯ -20.6608958 [10,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 ⋯ -20.6608958 [11,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 ⋯ -20.6608958 [12,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 ⋯ -20.6608958 [13,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 ⋯ -20.6608958 [14,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 ⋯ -20.6608958 [15,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 ⋯ -20.6608958 [16,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 ⋯ -20.6608958 [17,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 ⋯ -20.6608958 [18,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 ⋯ -20.6608958 [19,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 ⋯ -20.6608958 [20,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 ⋯ -20.6608958 [21,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 ⋯ -20.6608958 [22,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 ⋯ -20.6608958 [23,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 ⋯ -20.6608958 [24,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 ⋯ -20.6608958 [,13] [,14] [,15] [,16] [,17] [,18] [1,] 12.0150625 -4.3804583 -4.3804583 4.2420000 -0.7427083 -0.7427083 [2,] 12.0150625 7.5447500 12.0150625 -4.3804583 16.9899167 12.0150625 [3,] 4.2420000 -0.7427083 4.2420000 12.0150625 0.8358958 4.2420000 [4,] 0.8358958 16.9899167 -0.7427083 7.5447500 -4.3804583 0.8358958 [5,] -0.7427083 2.4279583 7.5447500 -0.7427083 4.2420000 7.5447500 [6,] -4.3804583 12.0150625 2.4279583 2.4279583 12.0150625 -4.3804583 [7,] 12.0150625 4.2420000 16.9899167 16.9899167 7.5447500 2.4279583 [8,] 2.4279583 0.8358958 0.8358958 0.8358958 2.4279583 16.9899167 [9,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 [10,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 [11,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 [12,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 [13,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 [14,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 [15,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 [16,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 [17,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 [18,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 [19,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 [20,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 [21,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 [22,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 [23,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 [24,] -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 -20.6608958 [,19] [,20] [,21] [1,] 2.4279583 -0.7427083 12.0150625 [2,] -4.3804583 -4.3804583 7.5447500 [3,] 4.2420000 2.4279583 -4.3804583 [4,] 0.8358958 0.8358958 16.9899167 [5,] 7.5447500 7.5447500 0.8358958 [6,] 16.9899167 16.9899167 2.4279583 [7,] 12.0150625 12.0150625 4.2420000 [8,] -0.7427083 4.2420000 -0.7427083 [9,] -20.6608958 -20.6608958 -20.6608958 [10,] -20.6608958 -20.6608958 -20.6608958 [11,] -20.6608958 -20.6608958 -20.6608958 [12,] -20.6608958 -20.6608958 -20.6608958 [13,] -20.6608958 -20.6608958 -20.6608958 [14,] -20.6608958 -20.6608958 -20.6608958 [15,] -20.6608958 -20.6608958 -20.6608958 [16,] -20.6608958 -20.6608958 -20.6608958 [17,] -20.6608958 -20.6608958 -20.6608958 [18,] -20.6608958 -20.6608958 -20.6608958 [19,] -20.6608958 -20.6608958 -20.6608958 [20,] -20.6608958 -20.6608958 -20.6608958 [21,] -20.6608958 -20.6608958 -20.6608958 [22,] -20.6608958 -20.6608958 -20.6608958 [23,] -20.6608958 -20.6608958 -20.6608958 [24,] -20.6608958 -20.6608958 -20.6608958
quantile_normalisation <- function(df){ df_rank <- apply(df,2,rank,ties.method="average") df_sorted <- data.frame(apply(df, 2, sort)) df_mean <- apply(df_sorted, 1, mean) index_to_mean <- function(my_index, my_mean){ return(my_mean[my_index]) } df_final <- apply(df_rank, 2, index_to_mean, my_mean=df_mean) rownames(df_final) <- rownames(df) return(df_final) } quantile_normalisation(Ct_full)
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [1,] 37.65081 19.91819 19.91819 16.28044 16.28044 16.28044 32.67596 19.91819 [2,] 16.28044 37.65081 32.67596 32.67596 37.65081 28.20565 23.08885 32.67596 [3,] 28.20565 28.20565 21.49679 24.90290 21.49679 21.49679 37.65081 23.08885 [4,] 21.49679 23.08885 21.49679 19.91819 19.91819 24.90290 21.49679 21.49679 [5,] 23.08885 24.90290 28.20565 21.49679 24.90290 32.67596 16.28044 28.20565 [6,] 19.91819 16.28044 24.90290 32.67596 32.67596 37.65081 19.91819 16.28044 [7,] 32.67596 32.67596 37.65081 32.67596 28.20565 19.91819 28.20565 37.65081 [8,] 24.90290 21.49679 16.28044 23.08885 23.08885 23.08885 24.90290 24.90290 [9,] 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 [10,] 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 [11,] 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 [12,] 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 [13,] 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 [14,] 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 [15,] 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 [16,] 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 [17,] 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 [18,] 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 [19,] 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 [20,] 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 [21,] 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 [22,] 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 [23,] 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 [24,] 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 [,9] [,10] [,11] [,12] [,13] [,14] [,15] [,16] [1,] 16.28044 28.20565 ⋯ 16.28044 32.67596 16.28044 16.28044 24.90290 [2,] 28.20565 19.91819 ⋯ 32.67596 32.67596 28.20565 32.67596 16.28044 [3,] 19.91819 21.49679 ⋯ 19.91819 24.90290 19.91819 24.90290 32.67596 [4,] 21.49679 16.28044 ⋯ 24.90290 21.49679 37.65081 19.91819 28.20565 [5,] 24.90290 23.08885 ⋯ 23.08885 19.91819 23.08885 28.20565 19.91819 [6,] 37.65081 32.67596 ⋯ 37.65081 16.28044 32.67596 23.08885 23.08885 [7,] 32.67596 32.67596 ⋯ 28.20565 32.67596 24.90290 37.65081 37.65081 [8,] 23.08885 24.90290 ⋯ 21.49679 23.08885 21.49679 21.49679 21.49679 [9,] 0.00000 0.00000 ⋯ 0.00000 0.00000 0.00000 0.00000 0.00000 [10,] 0.00000 0.00000 ⋯ 0.00000 0.00000 0.00000 0.00000 0.00000 [11,] 0.00000 0.00000 ⋯ 0.00000 0.00000 0.00000 0.00000 0.00000 [12,] 0.00000 0.00000 ⋯ 0.00000 0.00000 0.00000 0.00000 0.00000 [13,] 0.00000 0.00000 ⋯ 0.00000 0.00000 0.00000 0.00000 0.00000 [14,] 0.00000 0.00000 ⋯ 0.00000 0.00000 0.00000 0.00000 0.00000 [15,] 0.00000 0.00000 ⋯ 0.00000 0.00000 0.00000 0.00000 0.00000 [16,] 0.00000 0.00000 ⋯ 0.00000 0.00000 0.00000 0.00000 0.00000 [17,] 0.00000 0.00000 ⋯ 0.00000 0.00000 0.00000 0.00000 0.00000 [18,] 0.00000 0.00000 ⋯ 0.00000 0.00000 0.00000 0.00000 0.00000 [19,] 0.00000 0.00000 ⋯ 0.00000 0.00000 0.00000 0.00000 0.00000 [20,] 0.00000 0.00000 ⋯ 0.00000 0.00000 0.00000 0.00000 0.00000 [21,] 0.00000 0.00000 ⋯ 0.00000 0.00000 0.00000 0.00000 0.00000 [22,] 0.00000 0.00000 ⋯ 0.00000 0.00000 0.00000 0.00000 0.00000 [23,] 0.00000 0.00000 ⋯ 0.00000 0.00000 0.00000 0.00000 0.00000 [24,] 0.00000 0.00000 ⋯ 0.00000 0.00000 0.00000 0.00000 0.00000 [,17] [,18] [,19] [,20] [,21] [1,] 19.91819 19.91819 23.08885 19.91819 32.67596 [2,] 37.65081 32.67596 16.28044 16.28044 28.20565 [3,] 21.49679 24.90290 24.90290 23.08885 16.28044 [4,] 16.28044 21.49679 21.49679 21.49679 37.65081 [5,] 24.90290 28.20565 28.20565 28.20565 21.49679 [6,] 32.67596 16.28044 37.65081 37.65081 23.08885 [7,] 28.20565 23.08885 32.67596 32.67596 24.90290 [8,] 23.08885 37.65081 19.91819 24.90290 19.91819 [9,] 0.00000 0.00000 0.00000 0.00000 0.00000 [10,] 0.00000 0.00000 0.00000 0.00000 0.00000 [11,] 0.00000 0.00000 0.00000 0.00000 0.00000 [12,] 0.00000 0.00000 0.00000 0.00000 0.00000 [13,] 0.00000 0.00000 0.00000 0.00000 0.00000 [14,] 0.00000 0.00000 0.00000 0.00000 0.00000 [15,] 0.00000 0.00000 0.00000 0.00000 0.00000 [16,] 0.00000 0.00000 0.00000 0.00000 0.00000 [17,] 0.00000 0.00000 0.00000 0.00000 0.00000 [18,] 0.00000 0.00000 0.00000 0.00000 0.00000 [19,] 0.00000 0.00000 0.00000 0.00000 0.00000 [20,] 0.00000 0.00000 0.00000 0.00000 0.00000 [21,] 0.00000 0.00000 0.00000 0.00000 0.00000 [22,] 0.00000 0.00000 0.00000 0.00000 0.00000 [23,] 0.00000 0.00000 0.00000 0.00000 0.00000 [24,] 0.00000 0.00000 0.00000 0.00000 0.00000
  • Overall clarity (score = 0.25)

  • Correctness of the code (score = 0.25)

  • Exhaustive cover of required analysis (score= 0.25)

  • Interpretation of the results (score = 0.25)

  • Total Score = 1

INSTRUCTOR SCORE: 0.5

Final score = 9.75/11

** INSTRUCTOR FEEDBACK**:You really tryed hard to work out the solution. Please make sure you keept it going when you have real data. It more problematic but not at all hard. Refer to the solutions for finishing the motebook. So far well done. Score:8/12