Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to find homozygous recessive values
    primarykey
    data
    text
    <p>Stemming from an earlier question I had about trying to check whether a parent is the correct parent given the child's genotype (see <a href="https://stackoverflow.com/questions/18729152/checking-whether-a-string-expression-in-a-specified-variable-is-contained-in-s">Checking whether a &quot;string&quot; expression in a specified variable is contained in several other variables</a>)</p> <p>Now, I'm trying to see whether if the genotype of the child is a recessive genotype (having two of the same recessive values [alleles] for this gene). In this case, the child is always affected with the disease while the parents are not (the child is a proband). I have tried to figure out whether the parents and the child are homozygous, and kinda worked out whether the child matches the parent's genotype.... but from these two pieces of information I can't seem to to work out whether the child is homozygous recessive...</p> <p>Here is what I have so far (following the <a href="https://stackoverflow.com/questions/18729152/checking-whether-a-string-expression-in-a-specified-variable-is-contained-in-s">similar answer</a> from above):</p> <pre><code>homo &lt;- read.table("/.../Family1a/Family1a_vcf.txt", sep="\t", header=T) d &lt;- data.frame(list(mom = homo[c(1)], dad = homo[c(2)], child = homo[c(3)] ), stringsAsFactors = FALSE) check_homo &lt;- function(x) { #homo m1 &lt;- sapply(strsplit(as.character(d[,2]),"/"),function(x) x[1]) m2 &lt;- sapply(strsplit(as.character(d[,2]),"/"),function(x) x[2]) d1 &lt;- sapply(strsplit(as.character(d[,1]),"/"),function(x) x[1]) d2 &lt;- sapply(strsplit(as.character(d[,1]),"/"),function(x) x[2]) c1 &lt;- sapply(strsplit(as.character(d[,3]),"/"),function(x) x[1]) c2 &lt;- sapply(strsplit(as.character(d[,3]),"/"),function(x) x[2]) mom_homo &lt;- m1 == m2 dad_homo &lt;- d1 == d2 child_homo &lt;- c1 == c2 homo_matrix_d &lt;- matrix(c(dad_homo,child_homo), ncol=2, byrow=TRUE) homo_matrix_m &lt;- matrix(c(mom_homo,child_homo), ncol=2, byrow=TRUE) homo_match_dc &lt;- rowSums(homo_matrix_d) homo_match_mc &lt;- rowSums(homo_matrix_m) #which ones equal parents fam &lt;- strsplit(as.character(d[c(1, 2, 3)]), "/") names(fam) &lt;- c("mom", "dad", "child") mom_query &lt;- fam[["child"]] == fam[["mom"]] dad_query &lt;- fam[["child"]] == fam[["dad"]] fam_matrix &lt;- matrix(c(mom=mom_query, dad=dad_query), nrow=2) child_match_parents &lt;- rowSums(fam_matrix) #if child doesn't match parents and child_homo = recessive #if child does equal parents,if homo_parent and homo_child then child = dominant child_rec &lt;- ifelse((child_match_parents &lt; 1 &amp; child_homo == "TRUE"), "RECESSIVE", "OTHER") child_dom &lt;- ifelse((child_match_parents != 0 &amp; child_homo == "TRUE") &amp; (mom_homo == "TRUE" | dad_homo == "TRUE"), "DOMINANT", "OTHER") } child_recessive_tmp &lt;- data.frame(apply(x, 1, check_homo)) </code></pre> <p>It is the last two lines in the loop that aren't working. This whole thing could be wrong so I don't mind the frustrated responses. All in all, I want one variable saying whether the child's genotype is homozygous recessive or not. </p> <p>Edit:</p> <p>Example of data: There is one SNP per row. </p> <pre><code> Mom Dad Child rs1 A/A G/G A/G rs2 T/C T/C T/T rs3 A/A C/A A/A . . . rs100 G/C A/G C/A </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload