When I call the contrasts.fit function in the R package, limma, I get an error, which I suspect is due to the "." reason, python may not recognize contrasts.fit as a full function. Is this the reason, please? How should I fix this problem?
import pandas
import rpy2.robjects
from rpy2.robjects import r, pandas2ri
from rpy2.robjects.packages import importr
pandas2ri.activate()
list_2D = [[1.2, 2.3, 3.4, 1.1, 1.2, 1.3],
[1.2, 2.3, 3.4, 1.1, 1.2, 1.3],
[1.2, 2.3, 3.4, 1.1, 1.2, 1.3]
]
ExpDesign = pandas.DataFrame([[0, 0, 0, 1, 1, 1], [1, 1, 1, 0, 0, 0]]).T
ExpDesign.columns = ["D", "V"]
data = pandas.DataFrame(list_2D)
# print(data)
# print(ExpDesign)
limma = importr("limma")
fit = limma.lmFit(data, ExpDesign)
fit = limma.eBayes(fit)
contrast = limma.makeContrasts("D-V", levels=ExpDesign)
fit2 = limma.contrasts.fit(fit, contrast)
fit2 = limma.eBayes(fit2, trend=True)
Traceback (most recent call last):
File "E:/PythonProjects/pythonLearn/Rpy2/Test.py", line 29, in <module>
fit2 = limma.contrasts.fit(fit, contrast)
AttributeError: module 'limma' has no attribute 'contrasts'