Hi I have the two data sets. The first one is a list of genes linked to a given cluster (0-7):
# gene output
Cluster <- rep(0:7, each = 10)
Gene <- c("LMO3", "NEUROD6", "NFIB", "SNAP25", "RTN1", "CPE", "SOX11", "CSRP2", "VAMP2", "ID2", "EMX2", "LHX5-AS1","PEG10",
"HES1", "TRH", "WLS", "TPBG", "RPS29", "CRABP2", "RSPO3", "RPL17", "RPL7", "PTMA", "RPL36A", "HMGN2", "H2AFZ",
"NFIB", "PABPC1", "NEUROD6", "HNRNPH1", "PTN", "FABP7", "IGFBP2", "ID4", "C1orf61", "VIM", "RPS27L", "FABP5",
"SDCBP", "BNIP3", "TCF7L2", "NEFL", "HMGCS1", "GAP43", "GPM6A", "SQLE", "ID4", "MSMO1", "SCOC", "BASP1", "TTR",
"MEST", "TPBG", "MDK", "TMBIM6", "RCN1", "C8orf59","ID3","PKM", "PTN", "NCOR1", "ELAVL4", "NNAT", "ETFB",
"STMN2", "TUBA1A", "GNG3", "MALAT1", "SOX4", "TUBB2B", "CRYAB", "GFAP", "CHCHD2", "HOPX", "LGALS1", "SCRG1", "ISG15",
"AC090498.1", "B2M", "CLU")
df <- data.frame(cbind(Cluster, Gene))
The second is an index which provides cell-type annotations for specific combinations of genes:
# index
Type <- c("Radial Glia", "Excitatory Neuron ", "Inhibitory Neuron","Inhibitory Neuron",
"IPC","Excitatory Neuron ","Radial Glia","Microglia","IPC","Inhibitory Neuron")
Subtype <- c("early", "Layer IV", "SST-MGE1", "SST-MGE1", "IPC-div2",
"Parietal and Temporal", "oRG/Astrocyte", "Microglia", "IPC-new", "MGE2")
Markers <- c("TOP2A AURK HMGB CTNNB1", "PPP1R1B SCN2A RORB CRYM", "DLX6-AS1 DLX1 SST DCX", "ERBB4 SST DLX2 DLX5 DLX6-AS1",
"CCNB2 NEUROD4 KIF15 PENK HES6 ZFHX4 GLI3", "MEF2C STMN2 FLT ROBO CRYM", "AQP4 GFAP AGT DIO2 IL33",
"C1QB AIF1 CCL4 C1QC", "CENPK EOMES", "CCK LHX6 SCGN SST")
index <- data.frame(cbind(Type, Subtype, Markers))
I am trying to find specific combinations outlined in Markers from the list of genes in my df. When such a match is found the corresponding type and subtype would be returned. However, there's a couple of caveats that I am finding very difficult to wrap my head around.
- The lists for each cluster may contain multiple marker combinations - thus the function should go over each marker combination iteratively rather than stop when the first match is found.
- The index-matching process should operate on each cluster separately - i.e. check genes in cluster 0 for marker matches and return type/subtype(s), then repeat the steps for cluster 1 etc.
My project data consists of dozens of df-like outputs made up of varied numbers of respective clusters, each containing hundreds to thousands of genes. I have tried my best to search solutions online but I am unfortunately drawing a total blank here.
Any help/toughts/suggestions would be greatly appreciated.
Edit:
the out put could look like so:
Cluster Gene Type Subtype
1 0 LMO3 Radial Glia early
2 0 NEUROD6 <NA> <NA>
3 0 NFIB <NA> <NA>
4 0 SNAP25 <NA> <NA>
5 0 RTN1 <NA> <NA>
6 0 CPE <NA> <NA>
where a correct match(es) would add a row(s) to the df with corresponding type and subtype for each cluster, leaving the remainder empty (NAs).