0

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
camille
  • 16,432
  • 18
  • 38
  • 60
Glen
  • 23
  • 3
  • Are you looking for python-based lex/yacc solutions? Your question doesn't suggest any python-based solutions. If you don't intend for it, please be mindful of your tags when you apply them. (If you haven't read about them, mouse-over [tag:ply] or read about it here: https://stackoverflow.com/tags/ply/info.) – r2evans Aug 15 '19 at 21:22
  • Not clear what do you want to do. Do you want to count the number of unique ID in daughter1.id and daughter2.id for each cell.id? An example output would be helpful if you can provide one. – www Aug 15 '19 at 21:30
  • Sorry! I wanted a solution based on R. I have updated the question now. About: Do you want to count the number of unique ID in daughter1.id and daughter2.id for each cell.id? Yes, would be one case – Glen Aug 15 '19 at 21:55
  • 1
    I really don't see how your intended output is related to your input. Please clarify. It would help if you give a reproducible dataframe as input with a reproducible data frame as intended output. See [How to make a great R reproducible example?](https://stackoverflow.com/q/5963269/4996248) for how to ask a question with reproducible data. – John Coleman Aug 15 '19 at 22:12
  • 2
    sounds like human cloning...you might want to check out `igraph` for help – chinsoon12 Aug 16 '19 at 00:21

0 Answers0