forked from nestorsaiz/saiz-et-al_2016
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstage.R
27 lines (27 loc) · 1.58 KB
/
stage.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
stage <- function(dataset){
# Given a certain dataset, evaluate the cell count of each embryo
# and assign values to a new 'Stage' columns accordingly
# >= 120 cells, Stage = '>120';
# <120 cells & >= 90 cells, Stage = '90-120';
# etc
dataset$Stage <- ifelse(dataset$Cellcount >= 150,
'>150',
ifelse(dataset$Cellcount >= 120 &
dataset$Cellcount < 150,
'120_150',
ifelse(dataset$Cellcount >= 90 &
dataset$Cellcount < 120,
'90_120',
ifelse(dataset$Cellcount < 90 &
dataset$Cellcount >= 64,
'64_90',
ifelse(dataset$Cellcount < 64 &
dataset$Cellcount >= 32,
'32_64', '<32')))))
# Convert 'Stage' into a factor with the levels ordered
# in increasing number of cells
dataset$Stage <- factor(dataset$Stage, levels = c('<32', '32_64',
'64_90', '90_120',
'120_150', '>150'))
return(dataset)
}