[BioC] problem with function

Iain Gallagher iaingallagher at btopenworld.com
Fri Dec 17 18:42:21 CET 2010


Hello List

I wonder if someone would help me with the following function.

cumulMetric <- function(deMirPresGenes, deMirs){
	
#need to match position of each miR in deMirPresGenes with its FC to form a vector of FC in correct order
	fc <- deMirs
	fcVector <- as.numeric(with (fc, FC[match(deMirPresGenes1[,4], Probe)] ) )

	#multiply fc by context score for each interaction
	metric <- fcVector * as.numeric(deMirPresGenes[,11])
	geneMetric <- cbind(deMirPresGenes[,2], as.numeric(metric))

 	#make cumul weighted score
	listMetric <- unstack(geneMetric, as.numeric(geneMetric[,2])~geneMetric[,1])
	listMetric <- as.data.frame(sapply(listMetric,sum)) #returns a dataframe
	colnames(listMetric) <- c('cumulMetric')

	#return whole list
	return(listMetric)
}

deMirPresGenes looks like this:

Gene.ID	Gene.Symbol	Species.ID	miRNA	Site.type	UTR_start	UTR_end	X3pairing_contr	local_AU_contr	position_contr	context_score	context_percentile
22848	AAK1	9606	hsa-miR-183	2	1546	1552	-0.026	-0.047	0.099	-0.135	47
19	ABCA1	9606	hsa-miR-183	2	1366	1372	-0.011	-0.048	0.087	-0.133	46
20	ABCA2	9606	hsa-miR-495	2	666	672	-0.042	-0.092	-0.035	-0.33	93
23456	ABCB10	9606	hsa-miR-183	3	1475	1481	0.003	-0.109	-0.05	-0.466	98
6059	ABCE1	9606	hsa-miR-495	2	1474	1480	0.005	-0.046	0.006	-0.196	58
55324	ABCF3	9606	hsa-miR-1275	3	90	96	0.007	0.042	-0.055	-0.316	94


The aim of the function is to extract a dataframe of gene symbols along with a weighted score from the above data. The weighted score is the FC column of deMirs * the context_score column of deMirPresGenes. This is easy peasy!

Where I'm falling down is that if I run this function it complains that 'geneMetric' can't be found. Hmm - I've run it all line by line (i.e. not as a function) and it works but wrapped up like this it fails!

e.g.

>testF2 <- cumulMetric(testF1, deMirs$up)
Error in eval(expr, envir, enclos) : object 'geneMetric' not found

deMirs$up looks like this:

Probe	FC
hsa-miR-183	2.63
hsa-miR-1275	2.74
hsa-miR-495	3.13
hsa-miR-886-3p	3.73
hsa-miR-886-5p	3.97
hsa-miR-144*	6.62
hsa-miR-451	7.94

Could someone possibly point out where I falling down.

Thanks

i

> sessionInfo()
R version 2.12.0 (2010-10-15)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_GB.utf8       LC_NUMERIC=C             
 [3] LC_TIME=en_GB.utf8        LC_COLLATE=en_GB.utf8    
 [5] LC_MONETARY=C             LC_MESSAGES=en_GB.utf8   
 [7] LC_PAPER=en_GB.utf8       LC_NAME=C                
 [9] LC_ADDRESS=C              LC_TELEPHONE=C           
[11] LC_MEASUREMENT=en_GB.utf8 LC_IDENTIFICATION=C      

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] tools_2.12.0
>



More information about the Bioconductor mailing list