This is a test version of Biostars. For the public version, visit https://www.biostars.org.
filtering samples

Hi all,

I do have list of samples as a txt file and want to only keep these samples from this large file; column name is samples name in the large file.

> col <- read.table("samples.csv", sep=",", header=FALSE)
> head(col)
      V1
1 DC103R
2 DC110R
3  DC115
4 DC120R
5 DC122R
6  DC124



count <- read.table("betas_1.csv", header=T, sep=",", as.is=T, na.strings="NA")
count[1:5,1:5]

                DC103R     DC110R      DC115      DC120R       DC122R
cg26928153   3.9541963   4.0022695    3.576284   3.6124026   3.5005138
cg16269199   3.1735810   3.2024469    2.532844   2.7646327   3.1078109
cg13869341   3.8688700   3.6512434    2.566684   3.6098174   3.0010929
cg24669183   3.1410903   3.1929830    4.492963   2.6653855   3.4812665

Could you please help me how I can do this.

r statistics

1 answer

Command line version: https://stackoverflow.com/questions/39551560/extract-column-using-grep

R version: https://stackoverflow.com/questions/24561936/grep-to-search-column-names-of-a-dataframe (and many others if you search for grep column r).

thanks it is sorted now.

Log in to answer this question.