Question: HELP WITH PYTHON! I have a very large .txt file that has been converted into a matrix consisting of two columns: phenotype and gene. How
HELP WITH PYTHON!
I have a very large .txt file that has been converted into a matrix consisting of two columns: phenotype and gene. How do I organize the matrix so that the row has the gene values and the column has the phenotype values?
Example of original matrix:
| Phenotype | Gene |
| green | A |
| blue | A |
| red | B |
| brown | C |
| orange | D |
| pink | E |
| purple | E |
Final edited matrix / .txt file
| Gene | green | blue | red | brown | pink | purple | orange |
| A | 1 | 1 | 0 | 0 | 0 | 0 | 0 |
| B | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
| C | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
| D | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
| E | 0 | 0 | 0 | 0 | 1 | 1 | 0 |
!!! How can I get the final matrix to contain '1' and '0' values, where '1' indicates that the gene has a corresponding phenotype, while '0' says it does not?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
