1
$\begingroup$

I have following table.

structure(list(n = c(29L, 11L, 10L, 10L), domain = c(1L, 5L, 
6L, 32L)), row.names = c(NA, -4L), class = c("tbl_df", "tbl", 
"data.frame"))

I need to retrieve rows from another table that corresponds to the values of the 1st column of the above table.

I did use following code by manually entering the column values of the table.

target <- c("1", "5", "6", "32")
selected_domains = filter(gene_domains, domain %in% target)

gene_domains is the second table.

I have other tables that have many rows and entering manually is impossible. So I will be grateful if someone can help me with this issue.

Thank you.

If you need, this is the second table (gene_domains).

structure(list(gene = c("ENSG00000230594 ENSG00000171155 ENSG00000224089 ENSG00000230347 ENSG00000236446 ENSG00000186471 ENSG00000101892 ENSG00000182890 ENSG00000232119 ENSG00000131721 ENSG00000101882 ENSG00000101883 ENSG00000242362 ENSG00000226685 ENSG00000125352 ENSG00000236126 ENSG00000237957 ENSG00000005893 ENSG00000125355 ENSG00000226600 ENSG00000125356 ENSG00000203989 ENSG00000226929 ENSG00000228517 ENSG00000177485 ENSG00000226023 ENSG00000236371 ENSG00000278646 ENSG00000158290", 
"ENSG00000176774 ENSG00000176746 ENSG00000232030 ENSG00000188408", 
"ENSG00000198205 ENSG00000215174 ENSG00000165591 ENSG00000198455 ENSG00000186787 ENSG00000204271 ENSG00000147059", 
"ENSG00000029993 ENSG00000166049 ENSG00000183862 ENSG00000102181 ENSG00000013619 ENSG00000130032 ENSG00000171100 ENSG00000160131 ENSG00000063601 ENSG00000147378 ENSG00000102195", 
"ENSG00000147099 ENSG00000067177 ENSG00000184388 ENSG00000225396 ENSG00000268994 ENSG00000198034 ENSG00000125931 ENSG00000269502 ENSG00000184911 ENSG00000275520", 
"ENSG00000102081 ENSG00000176988", "ENSG00000050030 ENSG00000131263 ENSG00000187969 ENSG00000147100", 
"ENSG00000102174 ENSG00000184735 ENSG00000175809 ENSG00000165186", 
"ENSG00000185448", "ENSG00000101977 ENSG00000101981", "ENSG00000177504 ENSG00000205642", 
"ENSG00000130150 ENSG00000101958 ENSG00000181544", "ENSG00000260802 ENSG00000077279 ENSG00000077274 ENSG00000101901", 
"ENSG00000062096 ENSG00000205667 ENSG00000101825", "ENSG00000169933", 
"ENSG00000134597 ENSG00000102078 ENSG00000056277 ENSG00000147262", 
"ENSG00000147256 ENSG00000171054 ENSG00000147255", "ENSG00000238210 ENSG00000169551 ENSG00000186376", 
"ENSG00000181191 ENSG00000130052 ENSG00000090776", "ENSG00000102409 ENSG00000182916 ENSG00000166681 ENSG00000185222 ENSG00000180964 ENSG00000204065 ENSG00000133134", 
"ENSG00000197565 ENSG00000101844 ENSG00000101842 ENSG00000101843", 
"ENSG00000267978 ENSG00000010404 ENSG00000123584 ENSG00000241489 ENSG00000268738 ENSG00000171116 ENSG00000269556 ENSG00000197620 ENSG00000185247 ENSG00000156009", 
"ENSG00000169906 ENSG00000047230 ENSG00000182287 ENSG00000182798 ENSG00000169249 ENSG00000126010", 
"ENSG00000005889 ENSG00000130741 ENSG00000123130 ENSG00000184831 ENSG00000165182 ENSG00000130066 ENSG00000174010", 
"ENSG00000204086", "ENSG00000001497 ENSG00000147065", "ENSG00000076770 ENSG00000123728", 
"ENSG00000169084 ENSG00000214717", "ENSG00000073464", "ENSG00000132446", 
"ENSG00000126970", "ENSG00000147246", "ENSG00000173674 ENSG00000184368 ENSG00000173681", 
"ENSG00000046647 ENSG00000198759 ENSG00000046653 ENSG00000196459 ENSG00000176896 ENSG00000123595 ENSG00000046651", 
"ENSG00000123561 ENSG00000123572", "ENSG00000183304 ENSG00000177138", 
"ENSG00000234469", "ENSG00000196368 ENSG00000224109", "ENSG00000004848", 
"ENSG00000174460 ENSG00000131724 ENSG00000175556", "ENSG00000131725", 
"ENSG00000087842 ENSG00000165197", "ENSG00000182220 ENSG00000234636 ENSG00000185753 ENSG00000238205 ENSG00000180182", 
"ENSG00000251192 ENSG00000147121 ENSG00000065923 ENSG00000102218 ENSG00000147119", 
"ENSG00000165175", "ENSG00000158301 ENSG00000198932 ENSG00000125962", 
"ENSG00000196767", "ENSG00000188158", "ENSG00000198798 ENSG00000214107 ENSG00000099399 ENSG00000120289 ENSG00000169297", 
"ENSG00000156697 ENSG00000122121 ENSG00000188706 ENSG00000122122 ENSG00000085185", 
"ENSG00000102362 ENSG00000101811 ENSG00000174225 ENSG00000188917 ENSG00000182489 ENSG00000007952", 
"ENSG00000131831 ENSG00000177324", "ENSG00000102172 ENSG00000230797", 
"ENSG00000215301 ENSG00000188937", "ENSG00000147223 ENSG00000089682 ENSG00000133131 ENSG00000133138 ENSG00000165376", 
"ENSG00000002586", "ENSG00000215113 ENSG00000147162 ENSG00000186810 ENSG00000215115 ENSG00000147174", 
"ENSG00000186288 ENSG00000186462", "ENSG00000101888 ENSG00000176076", 
"ENSG00000102128 ENSG00000133169", "ENSG00000157514 ENSG00000170935 ENSG00000147224 ENSG00000147234", 
"ENSG00000165194", "ENSG00000079482", "ENSG00000147003 ENSG00000130234 ENSG00000102010 ENSG00000165195", 
"ENSG00000146950 ENSG00000101850", "ENSG00000183837 ENSG00000235961 ENSG00000198681", 
"ENSG00000158164 ENSG00000198908", "ENSG00000008056 ENSG00000126756 ENSG00000126759 ENSG00000078061 ENSG00000126767 ENSG00000102265", 
"ENSG00000198814", "ENSG00000268009 ENSG00000165584 ENSG00000269791", 
"ENSG00000173698", "ENSG00000187268 ENSG00000205542 ENSG00000123594", 
"ENSG00000197976 ENSG00000196433", "ENSG00000102230 ENSG00000067992", 
"ENSG00000005302", "ENSG00000125363", "ENSG00000189037", "ENSG00000269405", 
"ENSG00000147394 ENSG00000147400 ENSG00000147383", "ENSG00000184788 ENSG00000124429 ENSG00000147180", 
"ENSG00000072506 ENSG00000158423 ENSG00000072501", "ENSG00000102226 ENSG00000102225 ENSG00000182872 ENSG00000130985 ENSG00000130988 ENSG00000147123", 
"ENSG00000122145", "ENSG00000147117 ENSG00000147124", "ENSG00000008086", 
"ENSG00000187808 ENSG00000198918", "ENSG00000101940 ENSG00000068354 ENSG00000015285 ENSG00000101945 ENSG00000102317 ENSG00000102312 ENSG00000147155", 
"ENSG00000130054", "ENSG00000273696 ENSG00000269586 ENSG00000270946 ENSG00000271449 ENSG00000181433 ENSG00000278085 ENSG00000169446 ENSG00000278289", 
"ENSG00000196664 ENSG00000101916", "ENSG00000091482 ENSG00000185915", 
"ENSG00000102158 ENSG00000226784 ENSG00000131174", "ENSG00000101846", 
"ENSG00000171659 ENSG00000171657", "ENSG00000260548 ENSG00000133124", 
"ENSG00000147130 ENSG00000147166 ENSG00000169562 ENSG00000147140", 
"ENSG00000126012", "ENSG00000130119", "ENSG00000187516 ENSG00000165169", 
"ENSG00000102109 ENSG00000126768 ENSG00000102100 ENSG00000102145 ENSG00000094631 ENSG00000068308 ENSG00000187682 ENSG00000102103 ENSG00000102096", 
"ENSG00000120509 ENSG00000120500 ENSG00000147127 ENSG00000186912 ENSG00000204195", 
"ENSG00000006756 ENSG00000157399 ENSG00000056998", "ENSG00000184083"
), domain = c(1L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 
13L, 14L, 15L, 17L, 18L, 20L, 21L, 28L, 30L, 31L, 32L, 33L, 34L, 
35L, 37L, 38L, 40L, 42L, 43L, 44L, 45L, 47L, 48L, 49L, 51L, 53L, 
54L, 56L, 57L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L, 67L, 68L, 
69L, 70L, 71L, 72L, 73L, 75L, 77L, 78L, 79L, 81L, 82L, 83L, 84L, 
85L, 89L, 90L, 91L, 96L, 99L, 102L, 105L, 108L, 109L, 111L, 113L, 
116L, 117L, 119L, 122L, 125L, 129L, 130L, 131L, 132L, 133L, 136L, 
142L, 143L, 144L, 145L, 150L, 161L, 165L, 168L, 169L, 174L, 175L, 
183L, 184L, 187L, 190L, 191L, 194L)), row.names = c(NA, 103L), class = "data.frame")
$\endgroup$
3
$\begingroup$

You just need to learn how to do a basic subset in R.

table1 <- structure(list(n = c(29L, 11L, 10L, 10L), domain = c(1L, 5L, 
6L, 32L)), row.names = c(NA, -4L), class = c("tbl_df", "tbl", 
"data.frame"))

selected_domains <- filter(gene_domains, domain %in% table1$domain)
| improve this answer | |
$\endgroup$
  • $\begingroup$ Thank you very much. $\endgroup$ – MudithMMBc Oct 11 '19 at 15:44
0
$\begingroup$

I changed

target <- c("1", "5", "6", "32")
selected_domains = filter(gene_domains, domain %in% target)

into

target <- over10$domain
selected_domains = filter(gene_domains, domain %in% target)

and it's the same thing that @Lynn has suggested. Thank you very much.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.