Extracting some part of a list
From your example we are comparing samples not genes, I think we need to run the test row wise, something like this:

pvalueGenes &lt;- sapply(colnames(biomarker),
                      function(i) t.test(biomarker[i, ],
                                         immune[i, ], paired = TRUE)$p.value)

names(pvalueGenes)[ pvalueGenes &lt; 0.05 ]