I have a a data frame with 10000 rows and multiple columns and I want to compute uniqueIds for each case in R:
cell.id mother.id daughter1.id daughter2.id
1 0 65 66
2 0 45 46
3 0 87 88
4 0 42 43
5 0 51 52
6 0 31 32
7 0 55 56
8 0 90 91
14 0 NA NA
where:
- mother.id - cell.id of this cell's mother cell (the cell which divided to give birth to this cell)
- daughter1.id - cell.id of one daughter cell (cell formed through this cell's division)
- daughter2.id - cell.id of second daughter cell (cell formed through this cell's division)
What I want to compute is cell.id how many daughters arise? or how many daughters each originate from daughter1.id and daughter2.id?
This could be as two new columns like Daughter1.id.children
and Daughter2.id.children
:
cell.id mother.id daughter1.id daughter2.id daughter1.id.children daughter2.id.children
1 52 65 66 2 2
2 40 45 46 1 0
3 66 87 88 0 0
4 2 42 43 2 1
5 45 51 52 2 2