I have downloaded two datasets, and I am trying to remove the genes they do not share in common. Is there a biocmanager package with a function that can compare their gene ids, match them and reorder them?


1 Answer 1


Assuming the datasets are arranged in matrices with one gene per row, this can be done by intersecting row names:

commonNames <- sort(intersect(rownames(data1.mat), rownames(data2.mat)));
filtered.data1.mat <- data1.mat[commonNames,];
filtered.data2.mat <- data2.mat[commonNames,];

It would be helpful if you could provide more information about your datasets. There are many other ways to do this, and the way that works best for you will depend on your particular situation.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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